Skip to content

Instantly share code, notes, and snippets.

@nowk
Created February 24, 2012 20:16
Show Gist options
  • Save nowk/1903463 to your computer and use it in GitHub Desktop.
Save nowk/1903463 to your computer and use it in GitHub Desktop.
Resource naming solutions
# 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