I am a rails noob so the below is probably down to lack of understanding however I have been looking/reading all day and cannot seem to find the solution.
I have two models - project and technology :
Project :
class Project < ActiveRecord::Base
attr_accessible description, :name
has_and_belongs_to_many :technologies, :join_table => :projects_technologies
end
Technology :
class Technology < ActiveRecord::Base
attr_accessible :abbr, :description, :name
has_and_belongs_to_many :projects, :join_table => :projects_technologies
end
My Create_Projects_Technologies migration was as follows :
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
I am then using Active Admin to create and edit Project models using the following form :
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
This correctly shows all my technologies as check boxes however as soon as I submit the form I hit the following error which I have not been able to overcome :
ActiveModel::MassAssignmentSecurity::Error in Admin::ProjectsController#update
Can't mass-assign protected attributes: technology_ids
All help is very much appreciate :D
Simple add technology_ids to Project attr_accessible
attr_accessible :client, :description, :name, :technology_ids
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With