javascript - How does "respond_with_navigational" work? -
i'm working devise , deviseinvitable manage authentication in app , i'm having trouble adding ajax support invitationscontroller#update. controller in deviseinvitable looks this:
# 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
this works when resource.errors.empty? == true
, execute:
respond_with resource, :location => after_accept_path_for(resource)
(i.e. invitations/update.js.erb rendered , javascript calls made). problem when resource.errors.empty? == false
, , execute:
respond_with_navigational(resource){ render_with_scope :edit }
the server says:
rendered invitations/update.js.erb (1.4ms)
but javascript calls not being run. can explain respond_with_navigational
supposed doing? i've been googling hours , haven't found explanation of api anywhere.
thanks!
ok, figure out respond_with_navigational
doing. it's defined in devise base classes such:
def respond_with_navigational(*args, &block) respond_with(*args) |format| format.any(*navigational_formats, &block) end end
and, navigational_formats
defined in devise well:
# returns real navigational formats supported rails def navigational_formats @navigational_formats ||= devise.navigational_formats.select{ |format| mime::extension_lookup[format.to_s] } end
so, it's wrapper respond_with()
. in order work, had add following invitationscontroller:
respond_to :html, :js
and now, update.js.erb
being rendered properly.
Comments
Post a Comment