Я новичок в рельсах и пытаюсь добавить ассоциацию own_to в мою модель Devise User. Ошибка, которую я получаю при попытке отобразить представление:
NoMethodError в Devise/registrations#edit undefined method `department_id' for #
Эта ошибка возникает в collection_select, на мой взгляд. Разве этот метод не предоставляется ассоциацией own_to?
Пользовательская модель
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable, :lockable and :timeoutable
devise :invitable, :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me
belongs_to :department
end
Изменить вид
%h2
Edit #{resource_name.to_s.humanize}
= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f|
= devise_error_messages!
%p
= f.label :email
%br/
= f.text_field :email
%p
= f.label :department
%br/
= collection_select(resource_name, :department_id, Department.all, :id, :name)
%p
...