Routing / in Rails

I am writing a simple Rails application with one main controller, and I want to map /(:action(:id))to this controller (basically remove the controller prefix at the beginning), but still there are path helpers that I get using map.resources,

I tried map.root :controller => 'notes'but get an error message:

undefined method `note_path 'for # <ActionView :: Base: 0x102038b50>

where i use the function link_to_unless_currentin my view.

Edit: Here is the code in index.html.erb that gives the error.

<% for note in category.notes %>
    <h3><%= link_to_unless_current h(numbered_title note), note %></h3>
<% end %>
+3
source share
1 answer

: , , , 3 , . , - 3. 2 ...

root , .

resources ( /notes) , notes_path. , , '/', :as, . , , :

resources '/', controller: :notes, as: :notes

, , notes. id .

:

resources '/', controller: :notes, as: :notes
resources :comments

/comments id.

resources :comments
resources '/', controller: :notes, as: :notes

/comments comments_controller#index.

0

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


All Articles