내 동영상 컨트롤러에서이 사용자 지정 작업이 있습니다내 앱이이 맞춤보기로 이동하도록하려면 어떻게해야하나요?
resources :videos do
member do
put 'topic_update'
get 'upvoted_songs'
end
end
그리고이 내 동영상 인덱스보기 링크 :
<%= link_to "Upvoted Songs", videos_path, :action => "upvoted_songs", :class => "upvoted_songs chosen_home_option" %>
및 전망
def upvoted_songs
@votes = current_user.videos_votes.where("value = 1")
@videos = @votes.videos.page(params[:page]).per(15)
end
이 내 경로입니다 videos/upvoted_songs.html.erb라는 파일
왜 링크가 upvoted_songs.html.erb보기로 연결되지 않고 비디오 색인보기로 유지됩니까?
UPDATE :이 내 routes.rb입니다
:
이ArgumentError
can't use member outside resource(s) scope
은 다음 페이지를 새로 고침 한 후, 나는이 오류가 :
나는 처음에이 오류가root :to => "videos#index"
resources :video_votes
resources :videos do
resources :comments
member do
put 'topic_update', :on => :member
get 'upvoted_songs', :on => :collection, :as => 'upvoted'
end
end
resources :comment_titles
resources :users
resources :profiles
resources :genres
resources :topics
resources :topicables
resource :session
ActionController::RoutingError in Videos#index
Showing /rubyprograms/dreamstill/app/views/videos/_video.html.erb where line #22 raised:
No route matches {:action=>"show", :id=>#<Video id: 485, title: "I'm Ready For You", description: nil, embed_code: nil, thumbnail_url: nil, released: nil, user_id: 57, created_at: "2011-04-02 08:47:36", updated_at: "2011-04-09 22:42:48", video_url: "http://www.youtube.com/watch?v=wy86KNtOjVg", video_votes_count: 0, vote_sum: 3, rank_sum: 28927.724512>, :controller=>"videos"}
22: <%= link_to video.title, video_path(video), :class => "normal" %>
호기심 : @votes = current_user.videos_votes.where ("value = 1")는> 1이 아니어야합니까? : P – corroded
아니, 왜냐하면 나는 사용자가 upvoted 모든 비디오를 검색하고 싶은데 내 앱에서 투표의 가치가 1 일 때이다. :) –
나는 당신이 모든 upvoted 투표를하고 싶다고 생각했다. 하지만 부울은 1보다 낫지 않습니까? 다시 물어보십시오 :) – corroded