Skip to content

Commit

Permalink
Add some attribute readers to migration module.
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Jul 13, 2009
1 parent b9f4ea7 commit 25647f7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
@@ -1,4 +1,4 @@
class <%= @migration_class_name %> < ActiveRecord::Migration
class <%= migration_class_name %> < ActiveRecord::Migration
def self.up<% attributes.each do |attribute| %>
<%= migration_action %>_column :<%= table_name %>, :<%= attribute.name %><% if migration_action == 'add' %>, :<%= attribute.type %><% end -%>
<%- end %>
Expand Down
@@ -1,4 +1,4 @@
class <%= @migration_class_name %> < ActiveRecord::Migration
class <%= migration_class_name %> < ActiveRecord::Migration
def self.up
create_table :<%= table_name %> do |t|
<% for attribute in attributes -%>
Expand Down
@@ -1,4 +1,4 @@
class <%= @migration_class_name %> < ActiveRecord::Migration
class <%= migration_class_name %> < ActiveRecord::Migration
def self.up
create_table :<%= session_table_name %> do |t|
t.string :session_id, :null => false
Expand Down
5 changes: 5 additions & 0 deletions railties/lib/generators/migration.rb
Expand Up @@ -5,6 +5,11 @@ module Generators
# just by implementing the next migration number method.
#
module Migration
def self.included(base) #:nodoc:
base.send :attr_reader, :migration_number,
:migration_file_name,
:migration_class_name
end

# Creates a migration template at the given destination. The difference
# to the default template method is that the migration number is appended
Expand Down

0 comments on commit 25647f7

Please sign in to comment.