Search code examples
ruby-on-railsruby-on-rails-3scaffoldingself

Scaffolding - rails generate - data migrate def in class


I'm new to Rails - I started a new rails app rails new test, then rails generate scaffold Name column1:datatype column2:datatype

In the tutorial once I open the 12345678timestamp_create_names.rb file I have def change, but the tutorial has both def self.up and def self.down

Why is that? And what is the difference? And should I edit my app now? And in the future?


Solution

  • migrations has changed from rails2 to rails3, now rails3 is smart enough to understand how it should response with your command

    So, consider change as a combination of up and down

    if you say

    rake db:migrate it will consider it as up

    rake db:rollback it will consider it as down

    read more here