I''m new to Rails and have been googling for days on this subject. Seems there used to be some built-in support for creating scaffolds for existing tables in earlier Rails versions, and several plugins/ addons that did similar things, but as far as I can tell none of them work with Rails 3. Am I correct in assuming that to bolt a Rails 3 GUI onto an existing database you have to manually define the fields for each table in the "generate" command? If so, what happened to DRY and when is this support expected for Rails 3? Thanks for any help/ideas. -- 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-/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.
Bryan Crossland
2011-Apr-16 06:32 UTC
Re: How to Generate Scaffold for Existing Table with Rails 3?
On Fri, Apr 15, 2011 at 4:12 PM, Lee <lhughes30-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Am I correct in assuming that to bolt a Rails 3 GUI onto an existing > database you have to manually define the fields for each table in the > "generate" command?You don''t have to manually define them in the generate command. You can add them by hand later.> If so, what happened to DRY and when is this > support expected for Rails 3? > >DRY is a concept. It means Don''t Repeat Yourself. The concept is applied to how you program your application. An example of violating DRY would be having the same method in three different places in your app. Having to define fields for a legacy database that you are now bolting a Rails app to is not a violation of this concept. However, this is all academic to your real issue. How do I connect my Rails 3 app to a legacy database? I think what you are looking for is something like DataMapper. It works with Rails 3 (when using the gem dm-rails) and is actively being developed/supported. You can learn more here: http://datamapper.org/ dm_rails information can be found on the datamapper.org site and at the source code location. https://github.com/datamapper/dm-rails They have tutorials on how to connect to legacy databases and lots of information on working with some of the issues that come do that. B. -- 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-/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.
David Kahn
2011-Apr-16 11:00 UTC
Re: How to Generate Scaffold for Existing Table with Rails 3?
On Fri, Apr 15, 2011 at 4:12 PM, Lee <lhughes30-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m new to Rails and have been googling for days on this subject. > Seems there used to be some built-in support for creating scaffolds > for existing tables in earlier Rails versions, and several plugins/ > addons that did similar things, but as far as I can tell none of them > work with Rails 3. >You should be able to run ''rails generate scaffold People last_name:string first_name:string...'' on rails 3. Though if you are working with legacy data you will just need to code by hand. I would say if you are really new, what I would do is create a test scaffold, that way you will get the generated files and you can copy the structures in building out your own views and controllers.> > Am I correct in assuming that to bolt a Rails 3 GUI onto an existing > database you have to manually define the fields for each table in the > "generate" command? If so, what happened to DRY and when is this > support expected for Rails 3? > > Thanks for any help/ideas. > > -- > 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-/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. > >-- 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-/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.