Routes in ruby on rails

2

I have the following routes:

resources :roles do
  resources :role_permissions do
    patch 'toggle_action/:id' => 'role_permissions#toggle_action'
  end
end

I create a link as follows:

role_role_permissions_path(@role, @role_permission, permission_action)

You should mount a route similar to the route below:

# => /roles/1/role_permissions/1/toggle_action/1

But you are generating a route like:

# => /roles/1/role_permissions/1.1

What could it be?

    
asked by anonymous 16.04.2015 / 14:08

1 answer

0

Just add a alias to the route:

resources :roles do
  resources :role_permissions do
      patch 'toggle_action/:id' => 'role_permissions#toggle_action', as: :toggle_action
  end
end

and to use it:

role_role_permission_toggle_action_path(@role, @role_permission, permission_action)

View the route:

  

role_role_permission_toggle_action PATCH /roles/:role_id/role_permissions/:role_permission_id/toggle_action/:id(.formform) role_permissions # toggle_action

    
16.04.2015 / 14:54