Created
February 24, 2012 20:16
-
-
Save nowk/1903463 to your computer and use it in GitHub Desktop.
Resource naming solutions
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
# Rails < 3 | |
class CustomerLocation < ActiveRecord::Base | |
def self.model_name | |
ActiveSupport::ModelName.new("Location") | |
end | |
end | |
# ActiveSupport::ModelName is moved or deprecated after 3 | |
# Rails 3+ | |
Long way http://pastebin.com/CJBMC3T0 | |
Or | |
class CustomerLocation < ActiveRecord::Base | |
def self.model_name | |
ActiveModel::Name.new("CustomerLocation", nil, "Location") | |
end | |
end | |
# url_for([@customer, @location]) | |
# customer_locations_path(@customer) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment