passing variables in redirect_to
ruby, ruby-on-rails, ruby-on-rails-3
Solution
redirect_to show_fail_path(:title => @post.title)
and take it from params[:title]
Problem
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?