![](/img/trans.png)
[英]Rails belongs_to association returning “Undefined Method” error
[英]Active Admin: belongs_to giving “undefined method” Error in Rails 4
當我使用belongs_to關系時出現以下錯誤
Admin :: PropertyDetailsController#index中的NoMethodError對於#AdminUser:0x00000005e59a70未定義方法`property_types'
請幫助解決問題。
我正在將ActiveAdmin 0.60與ruby 2.0.0p247和Rails 4一起使用。
Gemfile:gem'activeadmin',github:'gregbell / active_admin',分支:'rails4'
ActiveAdmin.register PropertyDetail do
belongs_to :property_type
menu :label => "Latest Properties in the Town"
controller do
def permitted_params
params.permit(:property_detail => [:title ,:description, :image_url, :price, :land_area, :land_unit, :contact_id, :property_type_id, :purpose_id])
end
end
index do
column :title
column :description
column :image_url
column :price, :sortable => :price do |property_detail|
div :class => "price" do
number_to_currency property_detail.price
end
end
end
form :partial => "form"
end
ActiveAdmin.register PropertyType do
end
我已經在github上發布了相同的問題,並且已經解決。 您可以在以下位置查看解決方案
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.