Saturday, September 8, 2012

Re: [Rails] A Question about Model and Database?

use def change
forget up and down def

cheers
Fahim Babar Patel

On Sat, Sep 8, 2012 at 9:55 AM, Javier Quarite <jquarites@gmail.com> wrote:
Rails is smart enough to determine if you want to create or drop a table if you have done the migration with change
def change
  #code here
end

it only depends on how you write the commands
if you do 
  rake db:migrate
then it will create the db (if the code inside change is about it) and if you do
  rake db:rollback 
it will drop that table
in other case then

def up
  #create table here
end

def down
  #drop table here
end

take a look here
and then here
there is a lot more on google

JavierQ

--
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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
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 post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate