In rails I enter the list action, it gives me a error about show action
Hey guys, I'm new to Rails. I'm very confused about this problem I have right now. When I hit the http://localhost:3000/videos/list
it gives me an error about not specifying the show action.
Here's my code
# routes.rb
Drumvideo::Application.routes.draw do
resources :videos
end
# videos_controller.rb
class VideosController < ApplicationController
def list
@videos = Video.order("videos.updated_at DESC")
end
end
# list.erb.html
<% @videos.each do |video| %>
<ul>
<li><%= video.title %></li>
<li><%= video.desc %></li>
<li><%= video.tudou %></li>
<li><%= video.drummers.first.first_name %></li>
</ul>
<% end %>
I think the problem is in the resources routes, But I don't know exactly how 开发者_开发百科to fix it.
change your routes.rb
to
Drumvideo::Application.routes.draw do |map|
resources :videos, :collection => {
:list => :get
}
end
The list action is very old in Rails and is not use any more. Whatever is recommending that you use it is outdated and should not be trusted.
Instead, read the Getting Started guide for how to properly use Rails now: http://guides.rubyonrails.org/getting_started.html
精彩评论