I''m just now getting around to trying out Rails 2. I used Rails 1 briefly. Back then I was able to start with an existing database that followed ActiveRecord conventions, run a few simple commands, and get a basic web app. up and running. It seems that has changed in Rails 2. Am I required to describe the columns of my tables for Rails 2 and/or modify generated code? I really want Rails to get information about the columns from my database schema and generate starting code for me. If I have to describe the tables myself, can someone point me at some documentation that describes the steps? -- R. Mark Volkmann Object Computing, Inc. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Rails 2 does everything rails 1.2 does and more. It does use SQLite3 however and you still have to set up migrations and database relations in your model. maybe read activerecord in the API... not quite sure what you''re asking. On Apr 8, 9:25 pm, "Mark Volkmann" <r.mark.volkm...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m just now getting around to trying out Rails 2. I used Rails 1 > briefly. Back then I was able to start with an existing database that > followed ActiveRecord conventions, run a few simple commands, and get > a basic web app. up and running. It seems that has changed in Rails 2. > > Am I required to describe the columns of my tables for Rails 2 and/or > modify generated code? I really want Rails to get information about > the columns from my database schema and generate starting code for me. > If I have to describe the tables myself, can someone point me at some > documentation that describes the steps? > > -- > R. Mark Volkmann > Object Computing, Inc.--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Tue, Apr 8, 2008 at 8:33 PM, edberner <eberner-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Rails 2 does everything rails 1.2 does and more. > It does use SQLite3 howeverI noticed that, so I ran "rails -dmysql addressbook" to create my addressbook application.> and you still have to set up migrations > and database relations in your model.I understand the part about setting up database relations in my model classes, but I didn''t used to have to set up migrations. Is there a way to generate the first migration from existing database tables? Maybe this is the key part I''m missing.> maybe read activerecord in the API... not quite sure what you''re > asking.I know pretty much about ActiveRecord. I have lots of Ruby code that is correctly accessing and modifying my database using ActiveRecord without using Rails outside the context of a web app. Now I''m trying to use that same database with Rails.> On Apr 8, 9:25 pm, "Mark Volkmann" <r.mark.volkm...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I''m just now getting around to trying out Rails 2. I used Rails 1 > > briefly. Back then I was able to start with an existing database that > > followed ActiveRecord conventions, run a few simple commands, and get > > a basic web app. up and running. It seems that has changed in Rails 2. > > > > Am I required to describe the columns of my tables for Rails 2 and/or > > modify generated code? I really want Rails to get information about > > the columns from my database schema and generate starting code for me. > > If I have to describe the tables myself, can someone point me at some > > documentation that describes the steps?-- R. Mark Volkmann Object Computing, Inc. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Mark, A migration is a change to the structure of a database, if you already have a database structure and you just want to access it in rails you don''t need a migration. Try: ruby script/generate model --skip-migration SomeExistingTable Note that rails makes assumptions about the tables it uses to store model data. You will need to override some of these assumptions if your DB schema isn''t what rails is after. For example, see: set_primary_key (http://localhost/rails-2.0.2-api/classes/ActiveRecord/ Base.html#M001400), set_table_name (http://localhost/rails-2.0.2-api/ classes/ActiveRecord/Base.html#M001399). - Barney On Apr 9, 11:47 am, "Mark Volkmann" <r.mark.volkm...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Tue, Apr 8, 2008 at 8:33 PM, edberner <eber...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Rails 2 does everything rails 1.2 does and more. > > It does use SQLite3 however > > I noticed that, so I ran "rails -dmysql addressbook" to create my > addressbook application. > > > and you still have to set up migrations > > and database relations in your model. > > I understand the part about setting up database relations in my model > classes, but I didn''t used to have to set up migrations. Is there a > way to generate the first migration from existing database tables? > Maybe this is the key part I''m missing. > > > maybe read activerecord in the API... not quite sure what you''re > > asking. > > I know pretty much about ActiveRecord. I have lots of Ruby code that > is correctly accessing and modifying my database using ActiveRecord > without using Rails outside the context of a web app. Now I''m trying > to use that same database with Rails. > > > On Apr 8, 9:25 pm, "Mark Volkmann" <r.mark.volkm...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I''m just now getting around to trying out Rails 2. I used Rails 1 > > > briefly. Back then I was able to start with an existing database that > > > followed ActiveRecord conventions, run a few simple commands, and get > > > a basic web app. up and running. It seems that has changed in Rails 2. > > > > Am I required to describe the columns of my tables for Rails 2 and/or > > > modify generated code? I really want Rails to get information about > > > the columns from my database schema and generate starting code for me. > > > If I have to describe the tables myself, can someone point me at some > > > documentation that describes the steps? > > -- > R. Mark Volkmann > Object Computing, Inc.--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Tue, Apr 8, 2008 at 10:47 PM, Barney <barn3y-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi Mark, > > A migration is a change to the structure of a database, if you already > have a database structure and you just want to access it in rails you > don''t need a migration. > > Try: ruby script/generate model --skip-migration SomeExistingTableFor anyone else interested in trying this, use two dashes before skip-migration. However, this still doesn''t work. The generated model .rb files and view .erb files still don''t know about the columns in my tables. I''m looking for a way to get those generated by automatically obtaining information about the columns from my database rather than having to explicitly tell Rails about the columns. Is that possible? It was in earlier versions of Rails.> Note that rails makes assumptions about the tables it uses to store > model data. You will need to override some of these assumptions if > your DB schema isn''t what rails is after. For example, see: > set_primary_key (http://localhost/rails-2.0.2-api/classes/ActiveRecord/ > Base.html#M001400), set_table_name (http://localhost/rails-2.0.2-api/ > classes/ActiveRecord/Base.html#M001399). > > - Barney > > On Apr 9, 11:47 am, "Mark Volkmann" <r.mark.volkm...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > On Tue, Apr 8, 2008 at 8:33 PM, edberner <eber...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Rails 2 does everything rails 1.2 does and more. > > > It does use SQLite3 however > > > > I noticed that, so I ran "rails -dmysql addressbook" to create my > > addressbook application. > > > > > and you still have to set up migrations > > > and database relations in your model. > > > > I understand the part about setting up database relations in my model > > classes, but I didn''t used to have to set up migrations. Is there a > > way to generate the first migration from existing database tables? > > Maybe this is the key part I''m missing. > > > > > maybe read activerecord in the API... not quite sure what you''re > > > asking. > > > > I know pretty much about ActiveRecord. I have lots of Ruby code that > > is correctly accessing and modifying my database using ActiveRecord > > without using Rails outside the context of a web app. Now I''m trying > > to use that same database with Rails. > > > > > On Apr 8, 9:25 pm, "Mark Volkmann" <r.mark.volkm...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > I''m just now getting around to trying out Rails 2. I used Rails 1 > > > > briefly. Back then I was able to start with an existing database that > > > > followed ActiveRecord conventions, run a few simple commands, and get > > > > a basic web app. up and running. It seems that has changed in Rails 2. > > > > > > Am I required to describe the columns of my tables for Rails 2 and/or > > > > modify generated code? I really want Rails to get information about > > > > the columns from my database schema and generate starting code for me. > > > > If I have to describe the tables myself, can someone point me at some > > > > documentation that describes the steps?-- R. Mark Volkmann Object Computing, Inc. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 9 Apr 2008, at 12:03, Mark Volkmann wrote:> > On Tue, Apr 8, 2008 at 10:47 PM, Barney <barn3y-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> Hi Mark, >> >> A migration is a change to the structure of a database, if you >> already >> have a database structure and you just want to access it in rails you >> don''t need a migration. >> >> Try: ruby script/generate model --skip-migration SomeExistingTable > > For anyone else interested in trying this, use two dashes before > skip-migration. > > However, this still doesn''t work. The generated model .rb files and > view .erb files still don''t know about the columns in my tables. I''m > looking for a way to get those generated by automatically obtaining > information about the columns from my database rather than having to > explicitly tell Rails about the columns. Is that possible? It was in > earlier versions of Rails.You might want to have a look at the dynamic_scaffolding plugin, which was extracted from rails for 2.0 that will only fiddle with the view files - nothing will happen to the model (but it''s never done anything there) Fred
On Wed, Apr 9, 2008 at 6:15 AM, Frederick Cheung <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > On 9 Apr 2008, at 12:03, Mark Volkmann wrote: > > > On Tue, Apr 8, 2008 at 10:47 PM, Barney <barn3y-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > Hi Mark, > > > > > > A migration is a change to the structure of a database, if you already > > > have a database structure and you just want to access it in rails you > > > don''t need a migration. > > > > > > Try: ruby script/generate model --skip-migration SomeExistingTable > > > > For anyone else interested in trying this, use two dashes before > skip-migration. > > > > However, this still doesn''t work. The generated model .rb files and > > view .erb files still don''t know about the columns in my tables. I''m > > looking for a way to get those generated by automatically obtaining > > information about the columns from my database rather than having to > > explicitly tell Rails about the columns. Is that possible? It was in > > earlier versions of Rails. > > You might want to have a look at the dynamic_scaffolding plugin, which was > extracted from rails for 2.0 > that will only fiddle with the view files - nothing will happen to the > model (but it''s never done anything there)Thanks! I''ll do that. I understand that many people feel that dynamic scaffolding is only useful for demos, not real web apps. I think what I really want is code generation for models. I want my models and views to be generated with content related to the fields in my tables. Is that supported out of the box by Rails 2? -- R. Mark Volkmann Object Computing, Inc. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---