On Viernes, 12 de Noviembre de 2010 13:49:52 odigity escribió:
> On Nov 12, 7:20 am, "Sergio Cambra .:: entreCables S.L. ::."
> 
> <[email protected]> wrote:
> > On Viernes, 12 de Noviembre de 2010 12:59:22 odigity escribió:
> > > Thanks for providing a practical solution.  Having a little trouble
> > > getting it to work, though.
> > > 
> > > It seems that the account_entity_id_form_column method isn't getting
> > > called.  I put a line in there that logs a test message, and it's not
> > > showing up in the output.
> > 
> > Do you get entity_id in your form? If you don't get it, add entity_id to
> > config.columns.
> 
> Yes:
>     config.columns = [:entity_type, :entity_id, :balance]
> 
> Both columns show up in the list (thought entity_id is title
> "Entity").  Still don't see account_entity_id_form_column being
> invoked.  :(

Are you using rails-2.3 branch?
In rails-2.3 branch you must use entity_id_form_column, and you won't get 
options hash, only input_name, so you will have to get id using 
active_scaffold_options_id:

def entity_id_form_column(record, input_name)
  column = active_scaffold_config.columns[:entity_id]
   select_options = if record.entity_type
     record.entity_type.constantize.all.map {|r| [r.to_label, r.id]}
   else
     []
   end
   select :record, :entity_id, select_options, :name => input_name, :id => 
active_scaffold_options(column)[:id]
end

> 
> > > I have ActiveScaffold set up under an admin/ subdirectory, so the
> > > controller is:
> > > /app/controllers/admin/accounts_controller.rb
> > > 
> > > Just to be certain I got the location and naming right, I created two
> > > helper modules, and pasted the method into both:
> > > /app/helpers/accounts_helper.rb  (Module AccountsHelper)
> > > /app/helpers/admin/accounts_helper.rb  (Module Admin::AccountsHelper)
> > 
> > You have to use admin/accounts_helper if your controller is inside admin
> > directory.
> 
> Cool, that's what I figured.  I'll delete the other one.
> 
> > > Seems to make sense to me, since we're trying to make it a drop-down
> > > box, but AS freaks out when do it.
> > > 
> > > Lastly, a theoretical question:  Why couldn't AS be modified to look
> > > at the models that are associated with :account as entities?  Doesn't
> > > Rails have both directions of the association available for
> > > introspection?
> > 
> > No, rails has no reverse association. AS tries to guess reverse
> > association using class_name, but it's not possible with polymorphic
> > association (it would try to get Entity class).
> 
> Ah... too bad.
> 
> > > Then AS could go and select all records in both tables
> > > and include them in the drop-down box.  That's ultimately what I'd
> > > prefer, and would be some awesome default logic to include.
> > 
> > It won't work, you won't be able to fill type and id foreign keys only
> > with a form, you won't know what class is selected. Two chained select
> > tags are needed.
> > 
> > You could build a select tag with both tables setting a custom value
> > which joins class name and id, and you should fill type and id fields in
> > the controller, but it must be custom code for each app.
> 
> I see what you're saying.
> 
> -ofer

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