On Martes, 23 de Junio de 2009 10:08:07 BaSS escribió:
> > I suppose you haven't defined the root path in your routes.rb:
> > config.root :controller => 'ControllerName'
>
> yes, i defined it.
>
> > If you want to redirect to an url, you can change root_path with the url
> > you want ('/', '/devices' or controller.devices_path for example)
> >
> > before_filter proc{|controller|
> >   controller.redirect_to controller.device_path unless
> > controller.params[:parent_controller]
> >
> > }
>
> if i try this example i have a similar error, if i try '/devices' i
> get a "you are using a protected method" error
>

Sorry, I usually use before_filter with a symbol and defining a method instead 
of a proc, and then you don't get protected method errors:

before_filter :check_nested
[...]
protected
def check_nested
        redirect_to devices_path unless params[:parent_controller]
end

> > You shouldn't use raise as a controller method (controller.raise), use
> > only raise:
> > before_filter proc{|controller|
> >   raise ActiveScaffold::ActionNotAllowed unless
> > controller.params[:parent_controller]
> >
> > }
>
> this seem to works, i get the exception if i go to /interfaces, but if
> i click in the nested table in /devices i get the exception too
>
> Any idea?

I have been checking my code and I check params[:parent_controller] sometimes, 
and other times I check params[:parent_column]. The best way would be "unless 
params[:parent_controller] || params[:parent_column]"
In nested scaffolds you get parent_column and parent_model
In nested create forms you get parent_controller, parent_column and 
parent_model
In nested update forms you get only parent_controller, other params are not 
needed.

-- 
Sergio Cambra .:: entreCables S.L. ::.
Mariana Pineda 23, 50.018 Zaragoza
T) 902 021 404 F) 976 52 98 07 E) [email protected]


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"ActiveScaffold : Ruby on Rails plugin" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/activescaffold?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to