Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save karlentwistle/7d459d0343f75feafca7 to your computer and use it in GitHub Desktop.
Save karlentwistle/7d459d0343f75feafca7 to your computer and use it in GitHub Desktop.
class Event < ActiveRecord::Base
has_many :artists
end
class Artist < ActiveRecord::Base
def self.make_me_an_artist
create! do |artist|
artist.cached_event_time = artist.event.time
end
end
end
event = Event.create(time: "3pm")
event.artists.make_me_an_artist
event.artists.first.cached_event_time #=> "3pm"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment