RailsCasts Pro episodes are now free!

Learn more or hide this

BrandonMathis's Profile

GitHub User: BrandonMathis

Site: http://brandonmathis.me

Comments by BrandonMathis


In the code !params[:redo] is going to evaluate the truthyness of an instance of String. Even though the contents of that string is 'true' or 'false' !params[:redo] will evaluate to false every time. This will cause your users to get stuck in a loop where 'redo' link is always displayed.

I would make the following changes to the rever action.

link_name = (params[:redo] == "true")? "undo" : "redo"
is_redo = false
is_redo = (params[:redo] == 'true')? true : false if params[:redo]
link = view_context.link_to(link_name, revert_version_path(@version.next, redo: !is_redo), :method => :post)
flash[:success] = "Undid #{@version.event}. #{link}".html_safe
redirect_to :back

How did you get this 'repeat' command?