On 7 September 2012 22:08, ACK <[email protected]> wrote:
> hi i m new to rails i need to know the => which is the best way to create
> Database table in Rails?
>
> 1) rails generate model User name:string email:string
> this will create a migration file with something like this
>
> class CreateUsers < ActiveRecord::Migration
>   def change
>     create_table :users do |t|
>       t.string :name # see here name column is already made becoz we have
> passed a parameters
>       t.string :email # same as above
>
>       t.timestamps
>     end
>   end
> end
>
>
> this is one method
>
> 2) rails generate model Page
> this will create a empty migration file something like this
>
> class CreatePages < ActiveRecord::Migration
>   def change
>     create_table :users do |t|
>       ===>>  now we can add here like t.string "name" to create column
> manually ========>>>>>
>       t.timestamps
>     end
>   end
> end
>
>
> So which is the good way to do above things example 1 or example 2?
> Please tell.

It is entirely up to you, do whichever you prefer.

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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to