我最近转向了Rails4,而我是。不。获得。的东西。至。工作...Rails4中的价格输入
ANSWER: As Aman remembered me, in Rails 4 we have to filter attributes in the Controller.
我要询价添加到我的房源脚手架。
1)生成一个迁移
rails g migration AddPriceToListings price:decimal
2)编辑迁移:
add_column :listings, :price, :decimal, :precision => 8, :scale => 2
3)添加输入到我的表格
<!-- Price Field -->
<div class="control-group">
<label class="control-label">Price</label>
<div class="controls">
<%= f.input :price, :placeholder => "0.00", label: false %>
</div>
</div>
4)在The Showpage
<%= number_to_currency(@listing.price, :unit => "$") %>
但是在我的Shopage里没有任何东西。价格不显示。它甚至不显示在数据库中。
有什么建议吗?
当我尝试这个时它看起来很好。 –
然后你不在Rails 4上,就像Aman回答(我忘记了),你必须在Listing Controller中过滤你的属性。 :) –
我的坏,我没有切换到Rails 4 .;) –