class Project < ActiveRecord::Base
has_many :pages
attr_accessible :name, :class_name, :content, :style
def bulk_update_pages(attributes)
for a in attributes do
pages.find(a['id'].to_i).update_attributes(a) if pages.exists?(a['id'])
end
end
end
class Page < ActiveRecord::Base
belongs_to :project
end
Is it a good way to bulk update pages from project ? Project.find(session[:ProjectId]).bulk_update_pages(params)
I think you’d be better off using a nested form:
http://railscasts.com/episodes/196-nested-model-form-part-1