Last active
August 29, 2015 14:26
-
-
Save liushooter/0d4faeec6a6101e936e4 to your computer and use it in GitHub Desktop.
rails delegate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Company | |
has_many :users | |
end | |
class User | |
delegate :name, to: :company, prefix: true | |
# User.last.company_name | |
belongs_to :company | |
def category_addr | |
category.addr | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment