Created
October 3, 2012 15:41
-
-
Save trekdemo/3827653 to your computer and use it in GitHub Desktop.
How to get relative model naming in rails before version 3.1
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
| 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