# :to argument to match() -- how is it converted to class/method name

**URL:** <https://www.ruby-forum.com/t/to-argument-to-match-how-is-it-converted-to-class-method-name/232773>\
**Category:** Rails\
**Created:** [October 27, 2014, 8:25pm UTC](https://www.ruby-forum.com/t/to-argument-to-match-how-is-it-converted-to-class-method-name/232773 "2014-10-27T20:25:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [October 27, 2014, 8:25pm UTC](https://www.ruby-forum.com/t/to-argument-to-match-how-is-it-converted-to-class-method-name/232773/1 "2014-10-27T20:25:53Z")

</div>

Is there any documentation for how the match command converts the “:to”  
argument to a class and method name?

If I have  
match ‘’, to: ‘#’,  
via: :get  
How does it go from to , 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.

---

<div class="post-metadata">

**Author:** ![brianspaid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/82dd89/32.png) [@brianspaid](https://www.ruby-forum.com/u/brianspaid)\
**Post date:** [October 28, 2014, 12:51pm UTC](https://www.ruby-forum.com/t/to-argument-to-match-how-is-it-converted-to-class-method-name/232773/2 "2014-10-28T12:51:51Z")

</div>

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.

> **[ActiveSupport::Inflector](https://api.rubyonrails.org/classes/ActiveSupport/Inflector.html#method-i-underscore)**
>
> The Inflector transforms words from singular to plural, class names to table names, modularized class names to ones without, and class names to foreign keys.

```
"MyFoo".underscore # => "my_foo"
"MyApp::Foo".underscore # => "my_app/foo"

```

> **[ActiveSupport::Inflector](https://api.rubyonrails.org/classes/ActiveSupport/Inflector.html#method-i-classify)**
>
> The Inflector transforms words from singular to plural, class names to table names, modularized class names to ones without, and class names to foreign keys.

```
"my_foo".classify # => "MyFoo"
"my_app/foo".classify # => "MyApp::Foo"

```
