On Monday, June 13, 2011 6:36:10 PM UTC-6, madth3 wrote:>
> Hi:
>
> I''m new to RoR and I apologize if this is a dumb question but
I''ve
> read the guides, searched the archives and found nothing.
>
> If I generate a model object and then the scaffold_controller the
> result is different than just running the scaffold generator (the
> _form partial has no fields in the first case).
> I did not expected this and I wanted to first create the models, tweak
> them and then generate the scaffolds.
>
> Did I made a mistake somewhere or is this by design?
>
> Ruby 1.9.2
> Rails 3.0.7
You didn''t make any mistake.
It''s just that the scaffold_controller generator is perhaps not as
smart as
you''d like it to be. It doesn''t parse your migrations (or look
at the
current state of the database) in order to determine what attributes might
exist on the associated model. As such, when creating your view templates,
it can''t build-out any references to any specific fields.
However, the regular scaffold generator has the benefit of knowing the
fields on the associated model because you provide them on the command line
as "field:type" pairs:
$ rails g scaffold MyModel name:string age:int [...]
If you really want your scaffolded view templates to include all your fields
in them, then I suggest simply using the regular scaffold generator _after_
having considered your data model enough to have a good, initial idea of
what fields you want.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-talk/-/Vg3tf1mWSGMJ.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.