This works perfectly. Thank you Sergio. And yes, I seem to be getting confused at the distinctoin between what is "Rails" in the GUI, and what is AS-specific. Like many here, coming from a C++ / Java / php - style syntax, to a Ruby syntax and the Rails framework, I feel like I am learning programming anew (and it is fun, and I so appreciate your help, and everyone else here who has helped me) -Janna
On May 12, 4:23 am, "Sergio Cambra .:: entreCables S.L. ::." <[email protected]> wrote: > El Monday 11 May 2009 22:07:08 JannaB escribió: > > > I have a table, 'statuses' as follows: > > id as int > > statusname as varchar > > autoadvanceto as int > > > The 'autoadvanceto' column references an id in the statuses table > > itself. (I have not specified any association in the Status model -- > > would I do both a belongs_to as well as a has many, with foreign_key > > => 'autoadvanceto' ?) > > Yes, you should do it. Then you can use > config.columns[:association_column].form_ui = :select, and you will get your > select without a form override. > You may need some custom association > options:http://wiki.github.com/activescaffold/active_scaffold/custom-associat... > > > > > > > My real question here, is in the module StatusHelper. I am setting up > > a select in form view of the autoadvanceto field so as to show the > > various statusnames to select from. This it does fine -except- it does > > not prepopulate the select box by setting the autoadvanceto that is > > already in the database for the given row, nor does it update the > > database if I change what is in the select box. > > > I've followed to docs very closely here I believe, specifically: > > >http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelp... > >l > > > Below is my attempt in my module StatusHelper to accomplish this. can > > anyone please tell me why my populated select box is not saving the > > selection on update, and why it is not selecting what the > > autoadvanceto value is if not 0 to begin with? Thank you, -Janna B. > > > def autoadvanceto_form_column(record, input_name) > > select("status", "autoadvanceto", getstatuses.collect {|p| > > [ p.statusname, p.id ] }, {:prompt => 'Select:'})#, :include_blank => > > true}) > > end > > That code will search @status.autoadvanceto, you should use select("record", > "autoadvanceto", ... because ActiveScaffold controllers method use @record to > get the record to be edited. > Also you should use the input_name, in some cases ActiveScaffold won't save > your field (in subforms for example): > > def autoadvanceto_form_column(record, input_name) > select("status", "autoadvanceto", getstatuses.collect {|p| [ p.statusname, > p.id ] }, {:prompt => 'Select:'}, :name => input_name) > end > > Anyway, using belongs_to and :select form_ui it's easier (and better IMHO) > > -- > Sergio Cambra .:: entreCables S.L. ::. > Nicolás Guillén 6, locales 2 y 3. 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 -~----------~----~----~----~------~----~------~--~---
