I have an “approval” of an action that displays a view that displays some content from a model (class). In the view, I have link_to that calls accept with the URL parameter (: id). After the accept action has completed (set to true), I would like to display approval again with the message ("Saved!"). However, unlike the static login page, the approval action requires a parameter on the first call. The second time it is displayed, a runtime error occurs (obviously). What is the best way to invoke flash notification approval ?
def approval @c = Class.find(params[:id]) end def accept @c = Class.find(params[:id]) @c.approve = true @c.save render 'approval', :notice => "Saved!" end
ruby-on-rails ruby-on-rails-3
Jackson henley
source share