Basically I''m looking for a way to get a drop-down list for an
enum-style field (since enum is not supported by AR, this amounts to
using a varchar field and calling validates_inclusion_of in the model).
Instead of a blank input in the scaffold, I''d like to call a get_input
method (see below) to read the enum created in validates_inclusion_of
and use it to create the drop-down. Is this possible?
My code looks like this:
class MyScaffoldingSandbox < ScaffoldingSandbox
include ActionView::Helpers::FormHelper
def default_input_block
Proc.new { |record, column| <<-END_ROW
<div class="row">
<span class="form">#{get_input(record, column)}</span>
</div>
END_ROW
}
end # default_input_block
def get_input record, column
if (column.limit == 1 and column.type == :string)
return check_box(record, column.name)
end
if (column.type == :text)
return text_area(record, column.name)
end
return input(record, column.name)
end
end # class MyScaffoldingSandbox
- Ben
On Jul 3, 2005, at 7:46 PM, Duane Johnson wrote:
>
> On Jul 3, 2005, at 1:32 PM, Ben Jackson wrote:
>> I''m trying to improve the scaffold generator, and one thing
I''d like
>> is to be able to check a record''s name against the class, and
put the
>> contents of validates_inclusion_of as a dropdown list in the view.
>> Is there some way to do this with introspection? Like
>>
>
> For some reason, I''m just not quite getting what you''re
trying to do.
> Is it that you want to be able to configure the scaffold generator
> from a point-and-click kind of interface?
>
> Duane Johnson
> (canadaduane)
>
>
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>