Last active
August 29, 2015 14:01
-
-
Save altherlex/da3580927d5a5cf1c423 to your computer and use it in GitHub Desktop.
Change the record path in link_to for RAILS3
This file contains 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
# When you call link_to in view, the record invoke a method named 'model_name' in Model | |
# <%=h link_to(@people.name, @people) -%> | |
# Rails 2 | |
Class People < ActiveRecord::Base | |
def self.model_name | |
ActiveSupport::ModelName.new('person') if SYSTEM=='CRM' | |
end | |
end | |
#----------------- | |
# Rails3 | |
Class People < ActiveRecord::Base | |
def self.model_name | |
ActiveModel::Name.new(People, nil, 'person') if SYSTEM=='CRM' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment