Reputation: 4502
In my Rails application, in routes.rb
I have
match "show_fail" => "Posts#show_fail"
In posts_controller.rb
:
def create
...
return redirect_to show_fail_path, :title => @post.title
end
def show_fail
end
In show_fail.html.erb
:
Unsuccessful posting of post title <%= title %>
But I got an error undefined local variable or method 'title'
. Why does it not know about the title
variable, and how can I fix it?
Upvotes: 4
Views: 3207
Reputation: 2258
redirect_to show_fail_path(:title => @post.title)
and take it from params[:title]
Upvotes: 4