" show ",: controller =>" admin / news "} lack of required ke...">

Using "news_path" for: a news resource does not work with `No route mappings {: action =>" show ",: controller =>" admin / news "} lack of required keys: [: id] '

I am implementing the admin subdomain and trying to find the answer to this question, but I have not found another instance.

My routes are as follows for the subdomain section:

constraints :subdomain => 'admin' do
  scope :module => "admin" do

    resources :news, :events
    match 'news', :to => 'news#index', :as => 'news'

    root :to => "dashboard#index"
  end
end

Events work fine, but for some reason, in order for the news to work, I need to add a specific route to match it. This may help show partial where the error is generated (admin / shared / menu):

<ul>
    <li><%= link_to 'Home', root_path, :class => "#{current_class?(root_path)}" %></li>
    <li><%= link_to 'News', news_path, :class => "#{current_class?(news_path)}" %></li>
    <li><%= link_to 'Events', events_path, :class => "#{current_class?(events_path)}" %></li>
    <div class="clearboth"></div>
</ul>

And then an error if I had to remove the matching route:

No route matches {:action=>"show", :controller=>"admin/news"} missing required keys: [:id]

I just don’t have a clue why, any thoughts?

+3
source share
2

, , - , → , . , .

+8

, Rails , , "" , . news'.singularize news; news.pluralize news ( , , ).

Rails news_path ( , ) news_path ( show).
news; , show , .

: news_index_path, . - , news.

ActiveAdmin .

news, Item, Entry, Object . NewsItem news_item_path news_items_path.

+3

All Articles