views:

109

answers:

1

I have a navigation system that provides a permalink for any link setup.

When i run the line through script/console this is what it returns:

>> Navigation.find_by_permalink("gems")
=> #<Navigation id: 10, text: "Gems", parent: nil, destination_controller: "pages", destination_action: "show", destination_id: "1", permalink: "gems", created_at: "2009-12-26 14:56:28", updated_at: "2009-12-26 14:56:28", previous: 9>

When i put into my app i get this:

ActiveRecord::RecordNotFound in NavigationsController#permalink

 Couldn't find Navigation without an ID

My Request was "/permalink/gems" and the associated route is:

map.permalink "permalink/:permalink", :controller => 'navigations', :action => 'permalink'

The Controller code that handles that request is:

def permalink
 @nav=Navigation.find_by_permalink(params[:permalink])
 redirect_to :controller => @nav.destination_controller, :action => @nav.destination_action, :id => @nav.destination_id
end

Anyone know why this is happening?

A: 

The Problem was caused by Declarative Authorization. It was using the permalink action RESTfully so my navigation find wasnt being used.

To disable Declarative Authorization for all actions bar the RESTful ones in a controller chage:

filter_resource_access

to:

filter_access_to :index, :show, :edit, :new, :create, :update, :destroy
Arcath