On Thursday 25 February 2010 09:30:33 Sergio Cambra .:: entreCables S.L. ::.
wrote:
> > > config.column[:catalog_items].includes = nil
> >
> > With any combination of the model containing "has_many :catalog_items"
> > and the controller having a preceding line "config.columns <<
> > :catalog_items" that line causes an error:
> >
> > undefined method `column' for CatalogItemsController:Class
>
> You don't need to add catalog_items to config.columns, it's an association
> and it's added by default.
Ok, but then what do I do? Setting "config.column[:catalog_items].includes =
nil" still gives the error above.
> Here is simplified:
> ...
Thank you!
> > 1) gives a working "Similar" link, but that link produces a table
> > containing all CatalogItems, not just the ones scoped by isotypecontrol.
> > Might be due to the error above?
>
> This must be used if you use an association and a nested scaffold. And
> don't forget to exclude association from include option:
> config.column[:catalog_items].includes = nil
Please see above, this won't work.
> > 2) contains the line "parent_record = find_if_allowed(params[:id],
> > :read)", which leads to an infinite recursion.
>
> This must be used if you use "similar" action link. find_if_allowed
> shouldn't lead to a recursion. It's only a find and a permission check,
> and it can raise an exception when record is not found or permission isn't
> granted.
I got it to work halfway using:
def beginning_of_chain
if action_name == 'similar'
parent_record = CatalogItem.find_by_id(params[:id])
super.isotypecontrol(parent_record.conjugate, parent_record.fragment,
parent_record.isotypeh, parent_record.origin)
else
super
end
end
I think the nested? never evaluated to true and parent_model is not in the
params-hash either when using the config.action_links.add approach. Also, the
find_if_allowed somehow caused an infinite recursion, so I replaced it as
above.
The problem now is that the link obviously isn't nested. Instead, the row is
replaced by the table showing similar records. I don't know what other :type
settings there are, but :nested does not work :)
How can I get this view to nest? config.nested.add_link seems to work only for
associations...
cheers,
ben
--
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.