1

This works:

resources :students do
    member do
      get 'frog'
    end
end

Here's what I understand it is to be doing: the resources method(?) is sending a code block to the member method(?) and telling it to create a GET action with the verb 'frog' (which is an entry in the controller, it has a view, etc.)

This also works:

resources :students do
    member do
      get :frog
    end
end

Pretty much the same, but what kind of data is :frog in this version?

I'm trying to understand every line of my scaffolded app rather than take anything on faith. All the tutorials claim the RESTful part is the difficult piece to understand, but I think that's pretty clear. It's the Rails conventions that are tripping me up.

Any explanations/expansions on the above are welcome.

crowhill
  • 2,398
  • 3
  • 26
  • 55

1 Answers1

1

In your example, :frog is a ruby symbol. It's easily converted to a string by call to_s on it (try :frog.to_s in irb or the console). Similarly, you can covert a string to a symbol by calling to_sym (try "frog".to_sym in irb or the console). The rails authors decided to accept either a string or a symbol in this case, since is trivial to change from one to the other.

Daiku
  • 1,237
  • 11
  • 20
  • Sure enough. That was it. Thanks!Having the google phrase "ruby symbol," I also found [this page](http://www.troubleshooters.com/codecorn/ruby/symbols.htm), was helpful. – crowhill Jun 02 '15 at 20:21