Ruby on Rails
Tuesday, October 28, 2014
This is not really documented anywhere, and tracing through the source is difficult. Within Rails the string inflector methods #classify and #underscore are used to go between snake-case names and camel-cased class and module names.
http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html#method-i-underscore
"MyFoo".underscore # => "my_foo"
"MyApp::Foo".underscore # => "my_app/foo"
http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html#method-i-classify
"my_foo".classify # => "MyFoo"
"my_app/foo".classify # => "MyApp::Foo"
On Monday, October 27, 2014 2:25:17 PM UTC-5, Brian Sammon wrote:
Is there any documentation for how the match command converts the ":to"
argument to a class and method name?
If I have
match '<path>', to: '<sort-of-a-class-name>#<sort-of-a-method-name>',
via: :get
How does it go from <sort-of-a-class-name> to <actual-class-name>, and
more importantly, how do I go in the reverse direction?
I can probably figure this out via trial-and-error, but I'd like to see
docs if there are some, or contribute some docs if not.
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/b0a230aa-7b16-423a-bf3d-8dc2b0fe4a4e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment