Rebin Joseph
2011-Nov-28 11:28 UTC
Creating Models from Scema.rb Possible?, I have 50 tables
Guys, I have experience with symfony frame work thats why asking the question here.Excuse me if I am wrong I have created a schema.rb file with definitions of 50 files and schema:load did creation of the tables. Now 1) I want to create models of these tables from schema.rb without entering the fields names in the command line. Is this possible? 2) I want to create controllers and views also with respect to it, possible?? db:migrate will destroying my well defined database table structure. IS there any way to keep the schema.rb without overwriting it? Please let me know the answers asap -- 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.
Colin Law
2011-Nov-28 13:43 UTC
Re: Creating Models from Scema.rb Possible?, I have 50 tables
On 28 November 2011 11:28, Rebin Joseph <rebinkjoseph-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Guys, > > I have experience with symfony frame work thats why asking the > question here.Excuse me if I am wrong > > I have created a schema.rb file with definitions of 50 files and > schema:load did creation of the tables. > > Now > > 1) I want to create models of these tables from schema.rb without > entering the fields names in the command line. Is this possible? > 2) I want to create controllers and views also with respect to it, > possible?? > > db:migrate will destroying my well defined database table structure. > IS there any way to keep the schema.rb without overwriting it? > > Please let me know the answers asapWith that many tables probably the quickest way (if you cannot find it already done by someone else) will be to write a script in whatever language you are most comfortable, to create a set of commands like rails generate scafffold <name> <field list with type> This will generate everything, including migrations so you can start with an empty database and run the migrations. If you do this make sure to publish it so that others will not have to repeat your work. Colin -- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Rebin Joseph
2011-Nov-28 14:29 UTC
Re: Creating Models from Scema.rb Possible?, I have 50 tables
How can I get the table and field list?. From schema.rb? db:migrate will destroying my well defined database table structure. IS there any way to keep the schema.rb without overwriting it? On Nov 28, 6:43 pm, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 28 November 2011 11:28, Rebin Joseph <rebinkjos...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > > > Guys, > > > I have experience with symfony frame work thats why asking the > > question here.Excuse me if I am wrong > > > I have created a schema.rb file with definitions of 50 files and > > schema:load did creation of the tables. > > > Now > > > 1) I want to create models of these tables from schema.rb without > > entering the fields names in the command line. Is this possible? > > 2) I want to create controllers and views also with respect to it, > > possible?? > > > db:migrate will destroying my well defined database table structure. > > IS there any way to keep the schema.rb without overwriting it? > > > Please let me know the answers asap > > With that many tables probably the quickest way (if you cannot find it > already done by someone else) will be to write a script in whatever > language you are most comfortable, to create a set of commands like > rails generate scafffold <name> <field list with type> > This will generate everything, including migrations so you can start > with an empty database and run the migrations. > > If you do this make sure to publish it so that others will not have to > repeat your work. > > Colin-- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law
2011-Nov-28 14:35 UTC
Re: Re: Creating Models from Scema.rb Possible?, I have 50 tables
On 28 November 2011 14:29, Rebin Joseph <rebinkjoseph-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: Please don''t top post, it makes it difficult to follow the thread. Insert your reply at appropriate points in previous message. Thanks.> How can I get the table and field list?. From schema.rb?That is what I meant to say, yes. Colin> db:migrate will destroying my well defined database table structure. > IS there any way to keep the schema.rb without overwriting it? > > > On Nov 28, 6:43 pm, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >> On 28 November 2011 11:28, Rebin Joseph <rebinkjos...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> >> >> >> >> >> >> >> >> > Guys, >> >> > I have experience with symfony frame work thats why asking the >> > question here.Excuse me if I am wrong >> >> > I have created a schema.rb file with definitions of 50 files and >> > schema:load did creation of the tables. >> >> > Now >> >> > 1) I want to create models of these tables from schema.rb without >> > entering the fields names in the command line. Is this possible? >> > 2) I want to create controllers and views also with respect to it, >> > possible?? >> >> > db:migrate will destroying my well defined database table structure. >> > IS there any way to keep the schema.rb without overwriting it? >> >> > Please let me know the answers asap >> >> With that many tables probably the quickest way (if you cannot find it >> already done by someone else) will be to write a script in whatever >> language you are most comfortable, to create a set of commands like >> rails generate scafffold <name> <field list with type> >> This will generate everything, including migrations so you can start >> with an empty database and run the migrations. >> >> If you do this make sure to publish it so that others will not have to >> repeat your work. >> >> Colin > > -- > 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@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- gplus.to/clanlaw -- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Robert Walker
2011-Nov-28 15:19 UTC
Re: Creating Models from Scema.rb Possible?, I have 50 tables
Rebin Joseph wrote in post #1034085:> Guys, > > I have experience with symfony frame work thats why asking the > question here.Excuse me if I am wrongThis reply is for your future reference, and are merely suggestions...> I have created a schema.rb file with definitions of 50 files and > schema:load did creation of the tables.It is typical for Rails developers to generate database tables as a series of migrations where tables are added throughout the development cycle of a project. The framework is designed this way because most Rails developers use Behavior/Test Driven Development (BDD/TDD) techniques.> Now > > 1) I want to create models of these tables from schema.rb without > entering the fields names in the command line. Is this possible?Say you have a "users" table in your database... Following is what the associated model file would look like: class User < ActiveRecord::Base end Yep, that is it. This is what "rails generate model user first:name last:name" would generate no matter how many fields you add to the underlying database table. Should be pretty easy for you to write a Ruby script that would generate your 50 model files.> 2) I want to create controllers and views also with respect to it, > possible??That could be tricky since that''s what "rails generate scaffold..." was designed to do. If you want to stray from the well defined path the framework creators provided for you, and blaze your own trail, then you''ve got a lot more work ahead of you than typical Rails developers who follow the path.> db:migrate will destroying my well defined database table structure. > IS there any way to keep the schema.rb without overwriting it?Yes. That''s correct. Hence the warning in http://guides.rubyonrails.org/migrations.html: ----- 6.1 What are Schema Files for? Migrations, mighty as they may be, are not the authoritative source for your database schema. That role falls to either db/schema.rb or an SQL file which Active Record generates by examining the database. They are not designed to be edited, they just represent the current state of the database. ----- -- Posted via http://www.ruby-forum.com/. -- 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.
Robert Walker
2011-Nov-28 15:22 UTC
Re: Creating Models from Scema.rb Possible?, I have 50 tables
Robert Walker wrote in post #1034116:> Yep, that is it. This is what "rails generate model user first:name > last:name" would generate no matter how many fields you add to the > underlying database table.Oops. Typed to hastily that should have read "rails generate model user first_name:string last_name:string". -- Posted via http://www.ruby-forum.com/. -- 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.
Rebin Joseph
2011-Nov-28 15:33 UTC
Re: Creating Models from Scema.rb Possible?, I have 50 tables
What about this?. Does this one have any disadvantges? http://magicmodels.rubyforge.org/ On Nov 28, 8:22 pm, Robert Walker <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Robert Walker wrote in post #1034116: > > > Yep, that is it. This is what "rails generate model user first:name > > last:name" would generate no matter how many fields you add to the > > underlying database table. > > Oops. Typed to hastily that should have read "rails generate model user > first_name:string last_name:string". > > -- > Posted viahttp://www.ruby-forum.com/.-- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Norbert Melzer
2011-Nov-28 16:32 UTC
Re: Re: Creating Models from Scema.rb Possible?, I have 50 tables
Am 28.11.2011 15:29, schrieb Rebin Joseph:> How can I get the table and field list?. From schema.rb? > db:migrate will destroying my well defined database table structure. > IS there any way to keep the schema.rb without overwriting it?rails g scaffold --help shows: ActiveRecord options: [--migration] # Indicates when to generate migration # Default: true Perhaps that is useful for you?
Rebin Joseph
2011-Nov-29 04:07 UTC
Re: Creating Models from Scema.rb Possible?, I have 50 tables
Whats the use of ''g'' here? On Nov 28, 9:32 pm, Norbert Melzer <timmel...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> Am 28.11.2011 15:29, schrieb Rebin Joseph: > > > How can I get the table and field list?. From schema.rb? > > db:migrate will destroying my well defined database table structure. > > IS there any way to keep the schema.rb without overwriting it? > > rails g scaffold --help > > shows: > > ActiveRecord options: > [--migration] # Indicates when to generate migration > # Default: true > > Perhaps that is useful for you? > > signature.asc > < 1KViewDownload-- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law
2011-Nov-29 07:28 UTC
Re: Re: Creating Models from Scema.rb Possible?, I have 50 tables
On 29 November 2011 04:07, Rebin Joseph <rebinkjoseph-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Whats the use of ''g'' here?rails g is a shorthand way of saying rails generate Note how much easier it is to understand my post when I reply inline after your question. In order to understand your question I first had to scroll down to the bottom to find out what " Whats the use of ''g'' here?" was referring to. Colin> > On Nov 28, 9:32 pm, Norbert Melzer <timmel...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >> Am 28.11.2011 15:29, schrieb Rebin Joseph: >> >> > How can I get the table and field list?. From schema.rb? >> > db:migrate will destroying my well defined database table structure. >> > IS there any way to keep the schema.rb without overwriting it? >> >> rails g scaffold --help >> >> shows: >> >> ActiveRecord options: >> [--migration] # Indicates when to generate migration >> # Default: true >> >> Perhaps that is useful for you? >> >> signature.asc >> < 1KViewDownload > > -- > 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@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >-- gplus.to/clanlaw -- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.