Skip to content

Instantly share code, notes, and snippets.

@tubbo
Forked from anonymous/gist:4252505
Created December 10, 2012 19:26
Show Gist options
  • Select an option

  • Save tubbo/4252730 to your computer and use it in GitHub Desktop.

Select an option

Save tubbo/4252730 to your computer and use it in GitHub Desktop.
Good idea?
class Editor < ActiveRecord::Base
belongs_to :user
def do_editor_stuff;end
end
writer = User.find(123)
writer.do_writer_stuff() if writer.is_writer?
editor = User.find(456)
editor.do_editor_stuff() if editor.is_editor?
class User < ActiveRecord::Base
has_one :writer
has_one :editor
delegate :do_writer_stuff, :writer
delegate :do_editor_stuff, :editor
def is_writer?
self.writer.present?
end
def is_editor?
self.editor.present?
end
end
class Writer < ActiveRecord::Base
belongs_to :user
def do_writer_stuff;end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment