4

在我的 Rails 应用程序中,routes.rb我有

match "show_fail" => "Posts#show_fail"

posts_controller.rb

def create
  ...
  return redirect_to show_fail_path, :title => @post.title
end

def show_fail
end

show_fail.html.erb

Unsuccessful posting of post title <%= title %>

但我得到了一个错误undefined local variable or method 'title'。为什么它不知道title变量,我该如何修复它?

4

1 回答 1

4

redirect_to show_fail_path(:title => @post.title)

并从 params[:title] 中获取

于 2012-10-19T16:20:13.773 回答