Jason Hsu, Android developer
2013-Apr-25 04:12 UTC
Getting Rails to work with an existing database instead of a new one
All of the Rails tutorials I''ve looked at seem to revolve around creating a new database and then making the contents of the database accessible through the web page. The URL http://localhost:3000/users gives you access to the user list after you enter the following commands: rails generate scaffold User name:string email:string rake db:create:all rake db:migrate But what if you already created the user database with data in it? What is the alternative procedure for providing access to the user database at http://localhost:3000/users ? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/8AorzSj8_ZEJ. For more options, visit https://groups.google.com/groups/opt_out.
William Herry
2013-Apr-25 06:20 UTC
Re: Getting Rails to work with an existing database instead of a new one
that comment will generate controller, model and migration(used to create table), you can generate them separately On Thu, Apr 25, 2013 at 12:12 PM, Jason Hsu, Android developer < jhsu802701-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> All of the Rails tutorials I''ve looked at seem to revolve around creating > a new database and then making the contents of the database accessible > through the web page. The URL http://localhost:3000/users gives you > access to the user list after you enter the following commands: > > rails generate scaffold User name:string email:string > rake db:create:all > rake db:migrate > > > But what if you already created the user database with data in it? What > is the alternative procedure for providing access to the user database at > http://localhost:3000/users ? > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-talk/-/8AorzSj8_ZEJ. > For more options, visit https://groups.google.com/groups/opt_out. > > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Arvind Vyas
2013-Apr-25 06:42 UTC
Re: Getting Rails to work with an existing database instead of a new one
see this command will not generate the database this will generate the table name user , if you want to change the database go to the database.yml to change the database name. On Thu, Apr 25, 2013 at 11:50 AM, William Herry <WilliamHerryChina-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> that comment will generate controller, model and migration(used to create > table), you can generate them separately > > > On Thu, Apr 25, 2013 at 12:12 PM, Jason Hsu, Android developer < > jhsu802701-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> All of the Rails tutorials I''ve looked at seem to revolve around creating >> a new database and then making the contents of the database accessible >> through the web page. The URL http://localhost:3000/users gives you >> access to the user list after you enter the following commands: >> >> rails generate scaffold User name:string email:string >> rake db:create:all >> rake db:migrate >> >> >> But what if you already created the user database with data in it? What >> is the alternative procedure for providing access to the user database at >> http://localhost:3000/users ? >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Talk" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To view this discussion on the web visit >> https://groups.google.com/d/msg/rubyonrails-talk/-/8AorzSj8_ZEJ. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Colin Law
2013-Apr-25 08:01 UTC
Re: Getting Rails to work with an existing database instead of a new one
On 25 April 2013 05:12, Jason Hsu, Android developer <jhsu802701-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> All of the Rails tutorials I''ve looked at seem to revolve around creating a > new database and then making the contents of the database accessible through > the web page. The URL http://localhost:3000/users gives you access to the > user list after you enter the following commands: > > rails generate scaffold User name:string email:string > rake db:create:all > rake db:migrate > > > But what if you already created the user database with data in it? What is > the alternative procedure for providing access to the user database at > http://localhost:3000/users ?Just delete the migration file generated, and don''t run the rake commands. Alternatively just use generate model and generate controller and write the rest yourself (or just write it all yourself). If you use generate model then again delete the migration generated. That all assumes the existing table is rails compatible of course. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.