0
我有這樣的模式:創建自定義類的記錄,並simple_form
class User < ActiveRecord::Base
# abstract
end
class Company < User
end
class Person < User
end
如何創建表格類型的選擇?
<%= simple_form_for(@user) do |f| %>
<%# I would like to have a selector of classes ["Company","Person"] %>
<%= f.input :type %>
<%= f.input :name %>
<% end %>
在控制者,我應該寫什麼代碼?
@user = User.new(params[:user]) # Pb params[:user][:type] have no effect
你的意思是說你應該有類似Dropbox的東西,列出Company,Person的所有實體嗎? – uday 2012-04-06 13:44:55
你使用單表繼承嗎? – 2012-04-06 14:12:45