hi there,
    How do we share variables in a given data migration?

 For example,
 the code below fails to work because "statuses" don't seem to be in
scope for both up and down.


class AddDefaultValuesToStatuses < ActiveRecord::Migration
    statuses = [
        {
            'details' => 'details',
        },
        {
            'fitting_profile' => 'fitting profile',
        },
        {
            'live'  => 'published on site',
        },
        {
            'sold'  => 'auction ended',
        },
    ]


  def self.up
    statuses.each do |status|
      status.each do |name, display_title|
        @new_status = Status.new(
          :name          => name,
          :display_title => display_title,
          :created_by    => 'admin',
          :updated_by    => 'admin'
        ).save
      end
    end
  end

  def self.down
    statuses.each do |status|
      status.each do |name, display_title|
        @status = Status.searchlogic(
          :name          => name,
          :display_title => display_title
        )
        @status.delete
      end
    end
  end
end

-- 
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 this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to