我有這樣的代碼在我的控制器:爲什麼我可以接觸到新的創造方法回調控制器不工作對我來說
<%=link_to "Invite Friends", new_invitations_path, :remote =>true, :id => "invite_to_friends" %>
:
class InvitationsController < ApplicationController
before_filter :invitations_sent!
def new
#code here
end
def create
#code here
end
private
def invitations_sent!
if current_user.invitations.size > 1
return false
format.js { render :text => "you can not send more invitations" }
else
return true
end
end
end
我打電話跟法新如果我發送了3個邀請?
謝謝。你能否在問題中爲上述方法寫一個例子?非常感謝你! – hyperrjas 2012-03-06 16:33:15
如果我這樣寫:'如果current_user.invitations.size> 1個 \t format.js \t回假 \t end'我得到的錯誤:**引發ArgumentError(太少參數)... ** – hyperrjas 2012-03-06 16:58:36
該行認爲拋出錯誤是這樣的:'format.js {render:text =>「你不能發送更多的邀請」} 當這個條件滿足時返回false – hyperrjas 2012-03-06 17:15:47