Help with routes

Switching our routes file from Rails2 to Rails3 DSl uncovered an odd
situation, of my own making, but I am having some difficultly imagining
how to fix it.

Basically I have a commonplace: user -> user_role (clearance) <- role
type arrangement where:

User
has_many :roles, :through => :clearances
has_many :clearances

Clearance
belongs_to :role
belongs_to :user

and

Role
has_many :users, :through => :clearances
has_many :clearances

What I am trying to do is to link through new_user_role_path(@user).
But I get the following error when I try:

ActionController::RoutingError: No route matches
{:action=>“new”, :controller=>“user_roles”}

The thing is that when I run rake routes I see this:

new_user_role GET /users/:user_id/role/new(.:format)
{:controller=>“user_roles”, :action=>“new”}

So, I am somewhat nonplussed as to what is going on. I probably am
misunderstanding something basic but from my point of view it seems
that the route that is shown as missing is actually there. Is there
something else I am overlooking?

I should add that the link appears properly generated in the xhtml:

<%= link_to(I18n.t(‘Add New User Role’), new_user_role_path(@user),
:class => :new_user_role_link,
:id => :new_user_role_link_id) -%>

=>

Add New User Role

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs