我有一个模型:
class MyModel < ActiveRecord::Base
attr_accessible #.....
belongs_to :owner
end
还有一个控制器的动作:
def new
@data1 = MyModel.new
end
还有一个观点:
= f.select :owner_id, options_from_collection_for_select(MyModel.some_scope, :id, :full_name, @data1.owner.id)
显然,@data1.owner.id
是空的。如何使其“非空”?