0
我重寫在devise_invitable原代碼創建InvitationsController的方法,它看起來是這樣的:紅寶石大廈抽象協會在軌道上
def create
self.resource = resource_class.invite!(resource_params, current_inviter)
if resource.errors.empty?
set_flash_message :notice, :send_instructions, :email => self.resource.email
respond_with resource, :location => after_invite_path_for(resource)
else
respond_with_navigational(resource) { render :new }
end
end
我想一些fields_for添加到邀請形式,以便當我在此控制器中創建成員時,我可以構建與成員關聯的一些對象。我可以明確地這樣做,就像添加類似
resource.my_associations.build(params[:my_association])
是否有一種方法可以概括構建語句?或許暗示了參數的類名,並且在事先不知道它被稱爲什麼的情況下建立了關聯?