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

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