Oct 18, 11:40 am, Colin Law <clan...@googlemail.com> wrote:
> On 18 October 2011 16:25, prasetya utama <li...@ruby-forum.com> wrote:
>
> > yes i want to generate model, but the table has been created in
> > databases. And i want generate that table :)
>
> You say that you want to generate just the model, so you do not want
> to generate the full scaffold.  As I said previously there is no need
> to "generate" the model, just create a file models/your_model.rb with
> the class definition in as I showed in my first reply.  Rails will
> automatically pick up the fields from the database at run time.
>
This is a problem I am also facing - trying to set up a rails app with
a legacy database.  The minimal model file Colin suggests works fine
for access to the database, but I would love it if the scaffold (view,
controller, ...) files could be generated as if all the table fields
were explicitly used in the generate scaffold command.  I know I would
still need to modify them, but I would rather not have to add all the
fields for all the tables into the various view files.  I have found
Dr. Nic's magic_model_generator gem, and if I can get it to do what I
need with rails 2, which I am still not clear about, then I'll have to
see if I can modify it to work with rails 3.  Can anybody suggest
anything else that will generate a more complete (as in using the
fields from the database) set of view and other files?

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to