Displaying 2 results from an estimated 2 matches for "playlist_item".
Did you mean:
playlist_items
2007 May 28
2
Rails, respond_to? over anonymous module (extend has_many).
...9;m trying to generate examples for some list-helpers I have coded
which use in my projects.
Basically, the Playlist class uses one anonymous module in has_many
that acts as helper between acts_as_list and my desired API:
class Playlist < ActiveRecord::Base
# associations go here
has_many :playlist_items, :order => :position, :dependent => :destroy
has_many :assets, :through => :playlist_items, :order => :position do
def << (*assets)
assets.flatten.each do |asset|
item = proxy_owner.playlist_items.build(:asset => asset)
item.save unless proxy_owner....
2011 Nov 24
5
ActiveRecord::AssociationTypeMismatch
...no"}]}},
"id"=>"7",
"format"=>"xml"}
This are the three models:
class Image < ActiveRecord::Base
attr_accessor :picture
validates :name, :uniqueness => true, :presence => true
validates :picture, :presence => true
has_many :playlist_items
has_many :playlists, :through => :playlist_items
end
class Playlist < ActiveRecord::Base
validates :name, :presence => true, :uniqueness => true
has_many :playlist_items
has_many :images, :through => :playlist_items
accepts_nested_attributes_for :images, :allow_destroy =...