モデル記事があります。
移行ファイル:
class CreateArticles < ActiveRecord::Migration
def change
create_table :articles do |t|
t.string :name
t.string :description
t.string :body
t.string :keyword
t.integer :price
t.integer :count_text
t.integer :total_price
t.timestamps
end
end
end
私はArticlesController
2つの標準的な方法new
を持っていますcreate
私はnew.html.erb
ファイルを作成し、フォームヘルパーを使用しました。ただし、フィールドとcount_text total_priceは自動的に生成する必要があります(price * count_text)Count_text-は本文のサイズです。ユーザーがフィールドの本文にテキストを入力すると、テキストが計算されてから価格が乗算され、レコードの作成を確認する前にユーザーに表示されます。どうやって作るの?