我与制定和DeviseInvitable工作在我的应用程序来管理身份验证,我遇到了一些麻烦增加InvitationsController#更新AJAX的支持。在DeviseInvitable控制器看起来是这样的:“respond_with_navigational”是如何工作的?
# invitations_controller.rb
# PUT /resource/invitation
def update
self.resource = resource_class.accept_invitation!(params[resource_name])
if resource.errors.empty?
set_flash_message :notice, :updated
sign_in(resource_name, resource)
respond_with resource, :location => after_accept_path_for(resource)
else
respond_with_navigational(resource){ render_with_scope :edit }
end
end
这种运作良好,当resource.errors.empty? == true
,我们执行:
respond_with resource, :location => after_accept_path_for(resource)
(即邀请/ update.js.erb呈现和我的javascript调用制造)。问题是,当resource.errors.empty? == false
,我们执行:
respond_with_navigational(resource){ render_with_scope :edit }
服务器说:
Rendered invitations/update.js.erb (1.4ms)
但我的javascript调用没有运行。任何人都可以解释respond_with_navigational
应该做什么?我一直在Google上搜索几个小时,并且在任何地方我都没有找到这个API的解释。
谢谢!
来到这里是因为这个答案在这里:http://stackoverflow.com/a/9154096/18706(万一有人在寻找使用它的一个实际的例子)。 – mahemoff
此外,这是默认初始值设定项中的说明:https://gist.github.com/3824340 – mahemoff