How to render a different layout on registration error with devise in rails 3?
I am using rails 3 with devise and i want to render a special ajax error layout when there are errors in the devise registration. How can i have the devise create registration 开发者_Go百科action return an ajax layout i created when there are errors?
You can run:
rails generate devise:views
Which will put all the devise views in your app/views directory.
From there you can edit the views to whatever you want(including your ajax response).
You may also need to edit the controllers, form there you can read:
https://github.com/plataformatec/devise
Where they talk about configuring custom controllers.
Well in case this helps anyone else. I found out that i can make a .js.erb files that match the devise files and on remote it calls them. This worked except for on the registration form for some reason. On that form i had to add this code to my layout_by_resource code block.
respond_to do |format|
# format.js { "application" }
format.js { "../devise/registrations/new" }
format.html { "application" }
end
精彩评论