ruby on rails - Using if .present? redirect -
i feel simple i'm banging head against wall. i'm trying tell rails app if 1 parameter present (signature in example) want redirect home. here's code:
<%= if @pc.signature.present? %><% redirect_to "pages#home" %><%end%>
i keep running syntax error. in edit.html.erb file way.
perhaps in controller didn't define @pc? also, use path instead of 'pages#home'. should more this:
def edit @pc = pc.find(params[:id]) #or whatever logic redirect_to root_path if @pc.signature.present? # otherwise 'edit' template rendered end
Comments
Post a Comment