📜 ⬆️ ⬇️

rails scaffold news - how?

Comrades, how to implement a scaffold with a cute url "/ news /"?

To be honest, I was already tortured, if I called the whole thing “new”, so that the rails would decline to the plural, it would be like this:
NameError in News#index

Showing app/views/news/index.html.erb where line #24 raised:

undefined local variable or method `new_new_path' for #<ActionView::Base:0xf711a204>

Extracted source (around line #24):

21:
22:
23:
24: <%= link_to 'New new', new_new_path %>

RAILS_ROOT: /home/tenkoff/rails/test
Application Trace | Framework Trace | Full Trace

app/views/news/index.html.erb:24
app/controllers/news_controller.rb:7:in `index'



If you do try to give a different name and wrap it in roundabouts, it will be so
script/generate scaffold post title:string
and in the routes write the following:
map.resources :lenta, :controller => :posts

then all links will be on "/ posts /"

How does all this win?

')

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


All Articles