Ruby on Rails Friday, October 30, 2015

why dont you just do this....


class Artist < ActiveRecord::Base
has_many :events, dependent: :destroy
end

class Event < ActiveRecord::Base
belongs_to :artist
end

a = Artist.first
a.events which will return a list of events connected to that artist

e = Event.first
e.artist which will return the artist that is connected to that event.

Maybe explain what your user story is to better understand. With what
you posted I comprehended the statement above.

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/8be9ad7fa3b35df3628035d98ecf187b%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment