In my OrganizationsController in have this:
class OrganizationsController < ApplicationController
before_action :require_login
def show
@organization = current_user.organizations.find(params[:id])
end
end
And in 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>
routes:
URI pattern:
organization_repository GET /organizations/:organization_id/repositories/:id(.:format)
Link_to generates this URL:
/organizations/126/repositories/3
Whereas the organization_id is 3 and repository_id is 126 so the URL should rather be:
/organizations/3/repositories/126
How to generate proper URL?
/organizations/3/repositories/126