The update method is saving the data but the redirect is failing to render in the browser.
controller:
def update
fbc = FbComments.find(params[:id])
if fbc.update_attributes(params[:fb_comments])
session[:report_for] = current_user
redirect_to userhome_index_path
end
end
console:
Rendered userhome/_feedback_receive_list.html.erb (2.2ms)
Rendered userhome/_applet.html.erb (1.2ms) ...
Rendered userhome/_feedback_give_list.html.erb (1.2ms)
Rendered userhome/index.rhtml within layouts/user_app (9.1ms)
As you can see, the console says the view is rendering including its partials, but in reality the browser remains on the page with the form. Same result in Safari, Firefox or Chrome. I seem to remember reading something about a Rails 3.0.8 issue not rendering a view on a redirect but i can’t remember where or why. I am still researching… anybody know where the problem is?
Thank you.
NOTES:
I updated my controller with dpb’s suggestion below. And then followed krohrbaugh and dpb’s comments below which got rid of the 406 error. The controller code above is updated with their recommendations.
Experimenting, i changed the redirect url to pre-rest format but the outcome was the same so i changed it back. The data is still updated, but the redirect is still not rendering.
If you’re going to specify a format, you need a respond_to block. This should work:
Alternatively, if you only want to support html you can leave out the format.html all together like this:
You will probably also want to add an else statement just in case the update fails. Then you can handle it gracefully by redirecting or rendering another view.