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