Skip to content

Instantly share code, notes, and snippets.

@trekdemo
Created October 3, 2012 15:41
Show Gist options
  • Select an option

  • Save trekdemo/3827653 to your computer and use it in GitHub Desktop.

Select an option

Save trekdemo/3827653 to your computer and use it in GitHub Desktop.
How to get relative model naming in rails before version 3.1
require 'ostruct'
module RelativeModelNaming
def model_name
ActiveModel::Name.new OpenStruct.new( :name => self.name.split( '::' ).last )
end
end
# Example usage:
class Module::Model
extend RelativeModelNaming
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment