我有一个搜索字段,用户可以在其中输入反馈令牌编号,然后会出现相应的搜索反馈表。
因此在 feedback_controller.rb 文件中:
def find_token
@result_feedback = Feedback.find_by_token(params[:token_no]) #61153892
redirect_to feedbackresult_path
end
在路线:
match '/feedbackresult' => 'feedbacks#searchedfeedback'
在意见/反馈/searchedfeedback.html.erb
<%= @result_feedback.name %>
它抛出以下错误消息:
NoMethodError in Feedbacks#searchedfeedback
Showing /home/ajay/Documents/ROR/CAP/app/views/feedbacks/searchedfeedback.html.erb where line #1 raised:
undefined method `name' for nil:NilClass