Hi,
I usually do that:
class MyModel
STATUSES = [
[human_attribute_name('approved'), 'A'],
[human_attribute_name('rejected'), 'R'],
[human_attribute_name('pending'), 'P']
]
end
class MyController
active_scaffold do |config|
config.columns[:status].form_ui = :select
config.columns[:status].options = MyModel::STATUSES
end
end
module MyControllerHelper
def status_column record
MyModel.human_attribute_name record.status
end
end
But I has too much code and I don't know another way. This works like a
enum field, I never thinked about simplify that before.
I will wait for other's users suggestions.
Em Qui, 2009-10-01 às 15:23 +0900, EBIHARA, Yuichiro escreveu:
> Hi,
>
> My model has a "status" column to store the status of approval.
> The value can be one of "A" for approved, "R" for rejected and "P" for
> pending.
> I'd like to let users choose a value from a select list and I added
> the following lines in my controller.
>
> config.columns[:status].form_ui = :select
> config.columns[:status].options = {:options => [["Approved", "A"],
> ["Rejected", "R"], ["Pending", "P"]]}
>
> It works in Update view as I expect.
> Now I want the translated string ("Approved", "Rejected", "Pending")
> to be displayed in List and Show views, too.
> Is it possible to implement it "declaratively", instead of using field
> override?
>
> Thanks in advance,
>
> ebi
>
> >
--
Cordialmente,
Gabriel Sobrinho
Diretor de desenvolvimento
Hite Comunicação Digital e Mídia Interativa
http://www.hite.com.br/
+55 31 8775 8378
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---