You have more than one solution, i think of 2:
1. has_many is very configurable, check the api. You can make special
queries, filters, etc. This approach seems the best if your complex
logic is just on the find method.
2. put the special logic on a controller:
class FilteredTranslations < ActionController
active_scaffold :translations do |config|
...some config...
end
def conditions_for_collection
...some logic...
end
# use a before_filter to use session or user parameters.
# put before_filter :before_filter_config inside controller class
def before_filter_config
active_scaffold_config.label = "translations made by #
{current_user.name}"
end
# and last: add the nested link onto the other controller, and
intercepting the relation.
def self.active_scaffold_controller_for(klass)
return FilteredTranslationsController if klass == Translation
return "#{klass}ScaffoldController".constantize rescue super
end
On Feb 3, 9:13 pm, Robert Matei <[email protected]> wrote:
> Sorry if I wasn't clear; translations are a regular ActiveRecord model
> that's scaffolded.
>
> This case created a nested scaffold automatically:
> class App < ActiveRecord
> has_many :translations
>
> How do I do the same for this?
> class App < ActiveRecord
> def translations
> Translations.find( ...complex logic... )
>
> On Feb 3, 4:41 am, naaano <[email protected]> wrote:
>
> > Nested are scaffolds of associated models, so:
> > Question is, can you scaffold translations?
> > and i think to answer that: can you make a model out of translations?
> > However, that related to ROR, not this group.
>
> > On Feb 2, 6:38 am, Robert Matei <[email protected]> wrote:
>
> > > Say I have a method, app.translations, that returns an array of
> > > translations. To the scaffold the result should be the same as if it
> > > was a simple association, but the logic to get those translations is
> > > too complex for an association.
>
> > > Is there any way to have the translations nest in the apps controller?
>
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---