我form_for
在 Ruby on Rails 上遇到问题,使用 Ruby 2.0 和 Rails 4.0.0。
我按照本教程进行操作,一切都很完美,直到我添加了form_for
. 当我打开注册页面时,它会抛出:
Completed 500 Internal Server Error in 4ms
ActionView::Template::Error (no implicit conversion of Bignum into String):
3:
4: <div class="row">
5: <div class="span6 offset3">
6: <%= form_for User.new do |f| %>
7:
8: <%= f.label :name %>
9: <%= f.text_field :name %>
app/views/users/new.html.erb:6:in `_app_views_users_new_html_erb___700836681490305320_18582480'
这是我的 app/views/users/new.html.erb
<% provide(:title, 'Sign up') %>
<h1>Sign up</h1>
<div class="row">
<div class="span6 offset3">
<%= form_for(@user) do |f| %>
<%= f.label :name %>
<%= f.text_field :name %>
<%= f.label :email %>
<%= f.text_field :email %>
<%= f.label :password %>
<%= f.password_field :password %>
<%= f.label :password_confirmation, "Confirmation" %>
<%= f.password_field :password_confirmation %>
<%= f.submit "Create my account", class: "btn btn-large btn-primary" %>
<% end %>
</div>
</div>