Sergio, you rock.
To resume the solution for this issue:
class City < ActiveRecord::Base
belongs_to :nation
end
class User < ActiveRecord::Base
belongs_to :city
def nation
self.city.nation.name if self.city
end
end
class Admin::UsersController < ApplicationController
active_scaffold :user do |config|
config.columns = [:name, :description, :nation]
# Translation to Spanish
columns[:name].label = "Nombre"
columns[:city].label = "Ciudad"
columns[:nation].label = "Pais"
# Remove nation for edit purpose
create.columns.exclude :nation
update.columns.exclude :nation
end
end
Sergio thanks once again.
On Mon, Nov 3, 2008 at 10:04 AM, Sergio Cambra .:: entreCables - Symbol
Servicios Informáticos S.L. ::. <[EMAIL PROTECTED]> wrote:
>
> El Sunday 02 November 2008 23:59:15 LFung escribió:
> > How to place the label for virtual columns.
> >
> > class City < ActiveRecord::Base
> > belongs_to :nation
> > end
> >
> > class User < ActiveRecord::Base
> > belongs_to :city
> >
> > def nation
> > self.city.nation.name if self.city
> > end
> > end
> >
> >
> > class Admin::UsersController < ApplicationController
> >
> > active_scaffold :user do |config|
> > config.columns = [:name, :description]
> >
> > # Translation to Spanish
> > columns[:name].label = "Nombre"
> > columns[:city].label = "Ciudad"
> > columns[:nation].label = "Pais" # <--- The error occurred
> > while evaluating nil.label=
> > end
> > end
>
> You must add virtual columns (as your nation method) to AS columns
> (config.columns)
>
>
> --
> Sergio Cambra .:: entreCables - Symbol Servicios Informáticos 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
-~----------~----~----~----~------~----~------~--~---