I’m on Ruby on Rails section “Saving Data”: “5. Create Messages”. I’m finding that there’s a lot of code I’m writing that hasn’t been explained, but I think have roughly figured out.
For example, in the routes file we add:
get ‘/messages/new’ => 'messages#new’
This, I believe, maps a route from the /messages/new URL to the “new” method, as defined in the “messages_controller.rb” file. None of this is obvious to a learner. I feel that it needs to be explained to us:
- What the get function is, and what the general syntax (what is the rocket symbol for? We’ve not used this before??) is for using it in this instance.
- What and how Ruby/Rails is doing to go from the actual URL to “/messages/new”
- What is going on for " ‘messages#new’ " to mean “look in messages_controller.rb and access the ‘new’ method”. Somehow ‘messages’ = ‘messages_controller.rb’, but they clearly aren’t the same. How are we supposed to know this?
I’ve spent a few hours looking around on forums and have some vague idea of what’s happening, but it would help a lot if the lessons taught us some of the fundamentals before jumping in. I’ve spent a lot of time blindly following instructions only to get to the end and realise I have no idea what is going on.