jejacks0n / mercury

Mercury Editor: The Rails WYSIWYG editor that allows embedding full page editing capabilities directly inline.
http://jejacks0n.github.com/mercury
Other
2.63k stars 531 forks source link

display flash message when redirecting to mercury #334

Closed knorrli closed 11 years ago

knorrli commented 11 years ago

I'm trying to display a flash message after the update action, which gets lost somewhere in the mercury-controller. I don't fully understand mercury, but I managed to get it to work by adding flash.keep to the edit and resource action. If there is a way to do this on my end or I'm doing something stupid please let me know.

example controller code:

def update
    if @style.update_attributes(params[:style])
        flash[:notice] = "Style saved"
        redirect_to '/editor' + edit_style_path(@style)
    end
end
gvarela commented 11 years ago

Flash messages don't render for ajax requests. You would have to provide the flash message via json in order to provide that flash message from the server. In my opinion it is not the responsibility of the REST endpoint to provide that messaging. If you provide proper status codes (200 for success, 422 for failed update) you should handle that on the client side.