Hi,
I added a textarea to my edit student form, to be able to add tags to
this student. I did the simple code below, and this is the error i get.
I can’t see what i did wrong…
#Error message
Processing StudentsController#update (for 127.0.0.1 at 2010-02-14
10:13:22) [PUT]
Parameters: {“commit”=>“Submit”,
“authenticity_token”=>“PNvzBi6Ro1XJg0c6CfgKsEw+wfg6DwZfnV2FUpRgqPs=”,
“id”=>“1”, “student”=>{“full_name”=>"Gregory ", “cb_id”=>“68”,
“tag_attributes”=>“greg,toto”, “description”=>“voila une jolie
description”}}
Student Columns (12.8ms) SHOW FIELDS FROM students
Student Load (0.3ms) SELECT * FROM students
WHERE (students
.id
= 1)
WARNING: Can’t mass-assign these protected attributes: tag_attributes
#Html form
<% form_for @student do |f| %>
<%= f.error_messages %>
<%= f.label :cb_id %>
<%= f.text_field :cb_id %>
<%= f.label :full_name %>
<%= f.text_field :full_name %>
<%= f.label :description%>
<%= f.text_area :description %>
<%= text_area_tag "student[tag_attributes]" %>
<%= f.submit "Submit" %>
<% end %> #END#Student Class
class Student < ActiveRecord::Base
has_and_belongs_to_many :data_files
has_and_belongs_to_many :tags
attr_accessible :cb_id, :full_name, :description
validates_uniqueness_of :cb_id
def tag_attributes=(tags)
splits = tags.split(’,’)
splits.each do |tag|
Tag.build(tag)
end
end
end
#END
Thanks for your help
Greg