On 4 March 2010 05:51, Andy Jeffries <[email protected]> wrote:

>    How do we share variables in a given data migration?
>>
>
> Personally, in your case I'd declare it as a constant instead of a variable
> at the class level.
>
>

If it were a constant you'd never be able to change the value.  Is that
truly intended?



> 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]<rubyonrails-talk%[email protected]>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/rubyonrails-talk?hl=en.
>>
>>
>  --
> 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]<rubyonrails-talk%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>



-- 
Charles A. Lopez
[email protected]

What's your vision for your organization?
What's your biggest challenge?

Let's talk.
(IBM Partner)

-- 
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