On Viernes, 9 de Julio de 2010 11:03:45 Iñaki Baz Castillo escribió:
> 2010/7/9 Sergio Cambra .:: entreCables S.L. ::. <[email protected]>:
> > You have two problems here. You can't render an ActiveScaffold template
> > from a non-ActiveScaffold controller because view paths from
> > ActiveScaffold aren't added. You should copy _list_record.html.erb to
> > app/views/api.
> >
> > Also, id helpers such as element_row_id and active_scaffold_messages_id
> > use current controller to build the id, so id won't exist. You have to
> > send parent controller from the clients controller:
> >
> > controllers/clients_controller.rb:
> > --------------------------------------------
> >  config.action_links.add :block,
> >          :controller => :api,           # <---- NOTE
> >          :label => "Block.", :type => :member,
> >          :inline => true, :position => false,
> >          :crud_type => :update,
> >          :parameters => {:parent_controller => 'clients'}
>
> Thanks Sergio. However it's still not solved with it. I had also to
> copy _list_record_columns.html.erb to views/api/ (because it was
> missing) and still an error occurs:
>
> --------------------------------------------------------------
> Processing ApiController#block (for X:X:X:X at 2010-07-09 10:56:08) [GET]
>   Parameters: {"by"=>"client_id", "action"=>"block", "_method"=>"get",
> "id"=>"112", "controller"=>"api", "parent_controller"=>"clients"}
> Rendering api/block
>
> ActionView::TemplateError (undefined method `list' for nil:NilClass)
> on line #1 of app/views/api/_list_record_columns.html.erb:
> 1:   <%= content_tag :td,
> mark_record(marked_records.include?(record.id.to_s), :id =>
> record.id), :class => 'mark_record_column' if
> active_scaffold_config.list.mark_records %>
> --------------------------------------------------------------
>
> I understand it occurs because active_scaffold_config is nil for
> ApiController class (as it's not an AS controller).

Yeah, I forgot that, you should change active_scaffold_config.list.columns with 
an array, and maybe remove some code about permissions tests.

> I've also added api class to AS:
>
>     map.resources :api,                           :active_scaffold => true,
>
>         :collection => {:block => :get},
>         :member => {:block => :get}
>
> Should I also configure AS for this ApiController class? any other way?

If that controller will always display clients in list, you can configure AS in 
it, excluding all actions except list. It's the easiest way. I think you won't 
need to set :active_scaffold => true in your routes because you won't use 
specific AS actions.

>
> Thanks a lot.
> --
> Iñaki Baz Castillo
> <[email protected]>

-- 
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