我收到以下错误:
设计/注册#new Action Controller 中的 TypeError:异常捕获 - 无法将符号转换为整数
当我在下面添加 **'ed f.association 行时,我开始收到此错误。
这让我很费解,因为我遵循了 Rails 指南关联文档以及 simple_form 文档:
Simple_Form 示例
<%= simple_form_for @user do |f| %>
<%= f.input :name %>
<%= f.association :company %>
<%= f.association :roles %>
<%= f.button :submit %>
<% end %>
我的 Simple_Form 执行
<%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), html: { class: 'form-horizontal'}) do |f| %>
<%= f.error_notification %>
<%= f.input :email %>
<%= f.input :password %>
<%= f.input :password_confirmation %>
**<%= f.association :competition %>**
<div class="form-actions">
<%= f.submit "Sign up", class: "btn btn-primary" %>
</div>
<% end %>
<%= render "devise/shared/links" %>
这些是有问题的模型:
class Competition < ActiveRecord::Base
attr_accessible :name
has_many :rounds, :judges
end
class Judge < ActiveRecord::Base
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
attr_accessible :email, :password, :password_confirmation, :remember_me, :name
belongs_to :competition
end
我已经完成了以下迁移:
class AddAssocToJudges < ActiveRecord::Migration
def up
change_table :judges do |t|
t.belongs_to :competition
end
end
end
这是应用程序跟踪:
app/models/competition.rb:4:in `<class:Competition>'
app/models/competition.rb:1:in `<top (required)>'
app/views/devise/registrations/new.html.erb:9:in `block in _app_views_devise_registrations_new_html_erb__3768524909032037243_70228371062560'
app/views/devise/registrations/new.html.erb:3:in `_app_views_devise_registrations_new_html_erb__3768524909032037243_70228371062560'