Sorry, I am a little confused by this...

What is setting the @record instance variable?  How is that available
in the item helper?

Is that supposed to be "if association_name == :item_type" ?  instead
of an assignment?

...?

-patrick

On Jul 17, 8:59 pm, Hernan Astudillo <[email protected]> wrote:
> yeah, easier though:
>
> on item controller:
>
> config.columns[:item_type].form_ui = :select
>
> on item helper:
>
> def options_for_association_conditions(association)
>   if association_name = :item_type
>      {'item_types.animal' => @record.thing_type}
>   else
>     super
>   end
> end
>
> Then you handle the meows, wuffs and moooos in a separate controller
> using another model say, item_types, and cat, dog, cow, whatever in a
> column named animal for this example.
>
> There's another way to get it if you just need some static options:
> form_column_override. Check the wiki for that
>
>
>
> On Sat, Jul 16, 2011 at 6:42 PM, patrick99e99 <[email protected]> wrote:
> > Hi,
>
> > Say that I have two models: "Thing", and "Item"
>
> > Thing has two columns:  "name", and "thing_type"
> > Item has three columns:  "thing_id", "body", "item_type"
>
> > So,  Thing has_many :items and Item belongs_to :thing
>
> > ...
>
> > Is it possible to do something like this:
> > class ItemsController < ApplicationController
> >    active_scaffold :item do |config|
> >      config.columns[:item_type].form_ui = :select
>
> >      # pseudo code
> >      if config.parent_element.thing_type (meaning item.thing) ==
> > "Cat"
> >        options = [:meow, :purr]
> >      elsif config.parent_element.thing_type == "Dog"
> >        options = [:woof, :pant]
> >      end
>
> >      config.columns[:item_type].options = {:options => options}
>
> > ....
>
> > So in other words, if I go to create a new Thing record, I'd be able
> > to select a thing_type "Cat" or "Dog" and then it would build an item
> > record for the Thing-- but give me a select with options specific for
> > the "Cat" or "Dog" type..
>
> > Is there any way to do this with ActiveScaffold?
>
> > Thank you.
> > -patrick
>
> > --
> > 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 
> > athttp://groups.google.com/group/activescaffold?hl=en.

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