Я новичок в рельсах, поэтому нижеприведенное, вероятно, связано с отсутствием понимания, однако я искал/читал весь день и, похоже, не нашел решения.
У меня две модели -проект и технология:
Проект:
class Project < ActiveRecord::Base
attr_accessible description, :name
has_and_belongs_to_many :technologies, :join_table => :projects_technologies
end
Технология:
class Technology < ActiveRecord::Base
attr_accessible :abbr, :description, :name
has_and_belongs_to_many :projects, :join_table => :projects_technologies
end
My Create _Projects _Миграция технологий была следующей:
class CreateProjectsTechnologies < ActiveRecord::Migration
def self.up
create_table :projects_technologies, :id => false do |t|
t.references :project
t.references :technology
end
add_index :projects_technologies, [:project_id, :technology_id]
add_index :projects_technologies, [:technology_id, :project_id]
end
def self.down
drop_table :projects_technologies
end
end
Затем я использую Active Admin для создания и редактирования моделей проектов, используя следующую форму:
ActiveAdmin.register Project do
form do |f|
f.inputs "Project attributes" do
f.input :name
f.input :description
f.input :technologies, as: :check_boxes
end
f.buttons
end
end
Это правильно показывает все мои технологии в виде флажков, однако, как только я отправляю форму, я сталкиваюсь со следующей ошибкой, которую мне не удалось преодолеть:
ActiveModel ::MassAssignmentSecurity ::Ошибка администратора ::ProjectsController #обновление
Can't mass-assign protected attributes: technology_ids
Будем очень признательны за любую помощь :D