Can someone please explain to me in clear, unprofessional terms what a deal is with matching resources and named routes in Ruby on Rails?

This is the first time I have used Ruby in a project at my work, so I’m still learning a little rope (and love every minute).

As long as I understand the point in the functions map.connectin the route.rb file, I do not understand the "resources" and "named route" Rails functions. I have a Rails book here and read it several times, but I still don't understand it. I get named routes — I think that they are either rules, either explicitly defined or calculated by a block of code, but the resources for me are a complete mystery; the only thing that I woke up is that you simply NEED them if you want some of the cool things to work, for example, you could call "resource_path" (and its amazing sibling family of methods).

In my current project:

map.resources :application_forms
map.resources :sections
map.resources :questions
map.resources :seed_answers
map.resources :question_types
map.resources :form_questions
map.resources :rules
map.resources :form_rules

.. but in my Rails book there are such awesome has_many views and only-type hashes that dangle from them, and I can't figure out exactly when I should use them and what it is.

- ?

+3
3

- ; , , URL-. , .

- "", . , "" - , : " , . , . . ". - . , index, new, edit .. , , ; 'edit_section'.

:has_many , -. , map.resources :sections, :has_many => [:questions]. , , URL- . URL-, '/sections/27/questions/12', , 'section_questions'.

:only , " "; , , , .

+9

, Rails Routing Guide , . , == RESTful , .

+1

REST, DHH Rails RailsConf 2006 , , .

, , , , blog post, , , . , , REST, .

0

Source: https://habr.com/ru/post/1723963/


All Articles