在我的OrganizationsController中有这个:
class OrganizationsController < ApplicationController
before_action :require_login
def show
@organization = current_user.organizations.find(params[:id])
end
end
并在show.html.erb
<% @organization.repositories.each do |repository| %>
<%= link_to repository.name, organization_repository_path(repository) %>
<% end %>
PARAMS:
Parameters <ActionController::Parameters {"controller"=>"organizations", "action"=>"show", "id"=>"3"} permitted: false>
路线:
URI pattern:
organization_repository GET /organizations/:organization_id/repositories/:id(.:format)
Link_to生成此网址:
/organizations/126/repositories/3
而organization_id为3且repository_id为126,因此URL应该是:
/organizations/3/repositories/126
如何生成正确的网址?
/organizations/3/repositories/126