On Miércoles, 3 de Noviembre de 2010 14:09:42 Dan Candea escribió:
> On 11/03/2010 12:43 PM, Sergio Cambra .:: entreCables S.L. ::. wrote:
> > On Miércoles, 3 de Noviembre de 2010 11:30:54 Dan Candea escribió:
> >> On 11/03/2010 10:20 AM, Sergio Cambra .:: entreCables S.L. ::. wrote:
> >>> On Martes, 2 de Noviembre de 2010 14:54:45 Dan escribió:
> >>>> hello
> >>>> 
> >>>> I would appreciate some help with the issue below.
> >>>> 
> >>>> I have in a model a hash with array values, like this
> >>>> 
> >>>> class User<   ActiveRecord::Base
> >>>> 
> >>>>     LIST = { "Dan" =>   ["333","abc"] ,
> >>>>     
> >>>>              "John" =>   ["777","qwery"] ,
> >>>>           
> >>>>           }
> >>>> 
> >>>> end
> >>>> 
> >>>> class UserController<   ApplicationController
> >>>> 
> >>>>     active_scaffold :user do |config|
> >>>>     
> >>>>       config.label = "Test"
> >>>>       config.columns = [:name, :value]
> >>>>       config.columns[:name].form_ui = :select
> >>>>       config.columns[:name].options = {:options =>   User::LIST.map}
> >>>>       config.columns[:name].update_column = :value
> >>>>       config.columns[:value].form_ui = :select
> >>>>     
> >>>>     end
> >>>> 
> >>>> end
> >>>> 
> >>>> I what that on selection of a name from the User::LIST on :value field
> >>>> to be presented with the options from the array
> >>>> how can I do that?
> >>> 
> >>> You can't use :select form_ui in this case, you will have to make a
> >>> form override for value column
> >> 
> >> so I added
> >> 
> >> module UserHelper
> >> 
> >>     def value_form_column(record, input_name)
> >>     if record.name
> >>     
> >>       select_tag input_name, options_for_select(record.name)
> >>     
> >>     else
> >>     
> >>       select_tag input_name, options_for_select([])
> >>     
> >>     end
> >>     end
> >> 
> >> end
> >> 
> >> is this correct ?
> > 
> > No, you have to set the same id as AS set usually. If you are using
> > master branch you will get an options hash instead of input_name, so
> > it's easier: def value_form_column(record, options)
> > if record.name
> > select :record, :value, options_for_select(User::LIST[record.name]),
> > options ....
> > 
> > If you are using rails-2.3 branch, you can use
> > active_scaffold_input_options to get the id:
> > def value_form_column(record, input_name)
> > column = active_scaffold_config.columns[:value]
> > id = active_scaffold_input_options(column)[:id]
> > if record.name
> > select :record, :value, options_for_select(User::LIST[record.name]),
> > :name => input_name, :id =>  id
> 
> I get the id the same way even if  User belongs_to other record?
> I'm receiving the same RJS error  and I thins I receiving the wrong id

If you are accessing to parent record and user is a subform, you will have to 
pass scope to active_scaffold_input_options, and you will have to put the 
method in parent controller helper module, so it's easy in master branch.

> 
> > .....
> > 
> >> sorry for bottoring with this but the documentation is so light
> >> 
> >> when .update_column  is exexcuted i get
> >> 
> >> RJS error:
> >> TypeError: Cannot call method 'up' of null
> > 
> > You get that error because cannot get the field to update, because you
> > are not using AS id schema.
> > 
> >>>>    I searched all the docs but only possible solution is to use Custom
> >>>> 
> >>>> Association Options, but this means the values should be stored in the
> >>>> database
> >>>> 
> >>>> thank you

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