RailsCasts Pro episodes are now free!

Learn more or hide this

polosilva's Profile

GitHub User: polosilva

Comments by polosilva

Avatar

Was having problems Updating the widgets when saving a lecture through update_attributes(...). It was a matter of accessibility of the attributtes of widget.

lecture.rb
class Lecture < ActiveRecord::Base
  attr_accessible :name , :order , :html, :widgets_attributes 
  has_many :widgets
  accepts_nested_attributes_for :widgets,  :allow_destroy => true
end
widget.rb
class Widget < ActiveRecord::Base
    belongs_to :lecture
    attr_accessible :width, :height, :xpos, :ypos, :source
end

The last line of the widget class made all the difference.