문제

역사라는 방법이있는 컨트롤러가 있습니다.

class UsersController < ApplicationController

  def history
    User.return_history(params[:id])
  end

end

내 경로에 다음이 있습니다 .RB 파일

map.resources :users, :shallow => true do |user|
    user.resources :friends, :shallow => false
    user.resources :posts, :collection=>{:no_access => :get}
    user.resources :photos
end

ajax의 역사 방법을 어떻게 부르려고합니까? users_controller.rb? 사용 link_to_remote 다음 방법으로

link_to_remote 'History', :url=>history_user_path(@user), :update=>"history", :method=>'get'

나에게 오류를 던진다 history_user_path() 찾을 수 없습니다. 어떻게 이럴 수있어? edit_user_path() 오류가 표시되지 않으며 편집은 user.rb 파일에 명시 적으로 정의되지 않습니다. 감사.

도움이 되었습니까?

해결책

MapResources : 사용자는 edit_users_path를 포함하여 많은 URL/PATH 헬퍼 메소드를 만듭니다. 다른 사람이 필요하다면. Map.Resources에 대한 a : 멤버 또는 : 수집 옵션으로 추가해야합니다.

이것은 당신이 원하는 것을 할 수있게 해줄 것입니다.

map.resources :users, :shallow => true, :member => {:history => :get} do |user|
    user.resources :friends, :shallow => false
    user.resources :posts, :collection=>{:no_access => :get}
    user.resources :photos
end
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top