내가점 3.1
root :to => "posts#index"
devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" }
resources :users, :only => :show
resources :boards
resources :posts do
resources :comments
end
namespace :users do
resources :posts do
get :posts, :on => :member
end
resources :boards do
get :boards, :on => :member
end
end
레이크 노선 routes.rb 이이 레일 :
<% @posts.each do |post| %>
<%= link_to post.board.name, users_board_path(post.user, post.board) %>
<% end %>
: 나는이 개 매개 변수를 사용하여이 링크를 넣어 경우 boards_users_board GET /users/boards/:id/boards(.:format) {:action=>"boards", :controller=>"users/boards"}
users_boards GET /users/boards(.:format) {:action=>"index", :controller=>"users/boards"}
POST /users/boards(.:format) {:action=>"create", :controller=>"users/boards"}
new_users_board GET /users/boards/new(.:format) {:action=>"new", :controller=>"users/boards"}
edit_users_board GET /users/boards/:id/edit(.:format) {:action=>"edit", :controller=>"users/boards"}
users_board GET /users/boards/:id(.:format) {:action=>"show", :controller=>"users/boards"}
다음 URL에 점이 찍습니다.
이름 : (210)http://localhost:3000/users/boards/hyperrjas.board-2
- hyperrjas 내가 슬러그와 함께 넣어 한 USER_ID입니다.
- 중첩 리소스이므로 사용자를위한 패널이있어서 네임 스페이스를 사용합니다.
제 질문은 : 생성 된 URL에 점을 어떻게 바꿀 수 있습니까? 다음과 같이 모양과 작동합니다 : 중첩 된 것들 아래
http://localhost:3000/users/boards/hyperrjas/board-2
답장을 보내 주셔서 감사합니다. 원하는 것을 이해하지 못해서 조금 더 지정할 수 있습니까? 덕분에 – hyperrjas
어쨌든 네임 스페이스를 사용해야하는지 잘 모르겠습니다. 거기에 중첩 된 리소스를 사용해야합니다. (다른 답변을 게시 할게요) – Hock
자원이 잘 작동하는 데 감사드립니다. 그러나 컨트롤러로 ** 컨트롤러 **를 사용하고 컨트롤러 ** 사용자/보드 **로 작업하고 싶습니다. 이것은 내 문제입니다. 컨트롤러 ** 보드 **에서 리소스를 사용하여 작업하고 컨트롤러 ** 사용자/보드 **와 협력하고 싶다면 ** – hyperrjas