添加表单字段后,当我尝试在我的应用程序中查看页面时,我在 Statuses#new 中收到此错误NoMethodError ...我是 ruby on rails 的新手,所以很想能够完全理解这一点...
<%= f.input :user_id %>
这是完整的错误消息:
NoMethodError in Statuses#new
Showing /Users/danlee/Projects/treebook/app/views/statuses/_form.html.erb where line #14 raised:
undefined method `user_id' for #<Status:0x007feb53cdd138>
Extracted source (around line #14):
11: </div>
12: <% end %>
13:
14: <%= f.input :user_id %>
15: <%= f.input :content %>
16: <div class="form-actions">
17: <%= f.button :submit %>
Trace of template inclusion: app/views/statuses/new.html.erb
Rails.root: /Users/danlee/Projects/treebook
Application Trace | Framework Trace | Full Trace
app/views/statuses/_form.html.erb:14:in `block in _app_views_statuses__form_html_erb__4012047659275744874_70324335923840'
app/views/statuses/_form.html.erb:1:in `_app_views_statuses__form_html_erb__4012047659275744874_70324335923840'
app/views/statuses/new.html.erb:3:in `_app_views_statuses_new_html_erb___64465850179705865_70324349236340'
app/controllers/statuses_controller.rb:29:in `new'
Request
Parameters:
None
Show session dump
Show env dump
Response
Headers:
None
该应用程序的 Github 存储库也在这里:https ://github.com/pixeljugglerdan/treebook