On Jueves, 11 de Junio de 2009 13:32:08 JSeidel escribió:
> when I use
> config.columns{:type]...
> I get a string display of the record id of the type, not the value of
> the type itself in list; create, and update show a text box instead of
> a select box; update does show the record id of the type record
>
> when I use
> config.columns[:type_id]...
> I get the same display in list of the record id number, and create/
> update show a select box, but it's empty - not even record id numbers.
> And there is no value in the update select box, even though there is a
> value in the record being edited.
>
> I do try
> def to_label
> "Type: #{id}"
> end
>
> but that didn't seem to have any effect.
Try this in script/console:
AssetController.active_scaffold_config.columns[:type].association.nil?
AssetController.active_scaffold_config.columns[:type].singular_association?
They should return false and true
>
> On Jun 11, 4:00 am, "Sergio Cambra .:: entreCables S.L. ::."
>
> <[email protected]> wrote:
> > On Jueves, 11 de Junio de 2009 12:37:47 JSeidel escribió:
> > > Sorry; doesn't seem to help...
> > >
> > > If I use type and not type_id in config.columns, then list/create/
> > > update just display the id of the type record and it's a plain text
> > > field, not a select box.
> >
> > config.columns = [:type, ..]
> > config.columns[:type].label = "Item Type"
> > config.columns[:type].form_ui = :select
> > config.columns[:type].description = "The type of asset you are
> > creating."
> >
> > Create and update should show a select with all Type records. List should
> > show the value returned by to_label method in the associated type record.
> > If you don't define a to_label method, it will return name, label or
> > title attributes if exists, or record.to_s (usually
> > #<Type:memory_address>)
> >
> > > I don't understand what you mean by a "name" column, but I don't
> > > believe a to_label is needed; I have config.columns[:type_id].label
> > > for the type field (and it's working). I also have a config.list.label
> > > definition (wasn't shown), and that's also working.
> > >
> > > Yes, I know that the :foreign_key stuff isn't needed by Rails; I was
> > > just trying that since AS isn't working as expected.
> > >
> > > Thanks...
> > >
> > > On Jun 10, 9:13 pm, Kerry Foley <[email protected]> wrote:
> > > > config.columns uses type, not type_id
> > > >
> > > > Next, if you don't have a "name" column you'll need to define a
> > > > to_label method.
> > > >
> > > > |class User < ActiveRecord::Base
> > > >
> > > > def to_label
> > > > "User: #{username}"
> > > > end
> > > > end
> > > >
> > > > And you can drop the foreign_key stuff. It's assumed to be type_id.
> > > >
> > > > Docs:http://wiki.github.com/activescaffold/active_scaffold
> > > >
> > > > Regards,
> > > > Kerry
> > > >
> > > > JSeidel wrote:
> > > > > Hi... I have what I presumed to be a simple situation, but I
> > > > > haven't been able to get it to work; I'm sure it's something I'm
> > > > > overlooking.
> > > > >
> > > > > class Asset < ActiveRecord::Base
> > > > > belongs_to :type, :foreign_key => "type_id"
> > > > > end
> > > > >
> > > > > class Type < ActiveRecord::Base
> > > > > has_many :assets, :foreign_key => "type_id"
> > > > > end
> > > > >
> > > > > class AssetController < ApplicationController
> > > > > active_scaffold :asset do |config|
> > > > > config.columns = [:type_id, ..]
> > > > > config.columns[:type_id].label = "Item Type"
> > > > > config.columns[:type_id].form_ui = :select
> > > > > config.columns[:type_id].description = "The type of asset you
> > > > > are creating."
> > > > > end
> > > > >
> > > > > There are about 10 entries in type; I want to display the type name
> > > > > (string) in the list view but it displays the type_id number. In
> > > > > the Create and Edit views, it displays an empty select box.
> > > > >
> > > > > This should be one of the easiest things to do in AS (I'm in the
> > > > > process of upgrading from AjaxScaffold), but I sure can't figure it
> > > > > out.
> > > > >
> > > > > Any help is most appreciated.
> > > > >
> > > > > Thanks...jon
> >
> > --
> > 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]
>
>
--
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
-~----------~----~----~----~------~----~------~--~---