Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ensure class names exist first in migration
- Loading branch information
1 parent
ae20814
commit 327c2f0
Showing
1 changed file
with
8 additions
and
6 deletions.
There are no files selected for viewing
14 changes: 8 additions & 6 deletions
14
pages/db/migrate/20150720155305_update_slug_and_title_in_refinery_page_parts.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
class UpdateSlugAndTitleInRefineryPageParts < ActiveRecord::Migration | ||
def change | ||
Refinery::PagePart.all.each do |pp| | ||
unless pp.title | ||
pp.title = pp.slug | ||
begin | ||
::Refinery::PagePart.all.each do |pp| | ||
pp.title ||= pp.slug | ||
pp.slug = pp.slug.downcase.gsub(" ", "_") | ||
pp.save! | ||
end | ||
pp.slug = pp.slug.downcase.gsub(" ", "_") | ||
pp.save! | ||
rescue NameError | ||
warn "Refinery::PagePart was not defined!" | ||
end | ||
end | ||
end | ||
end |