Guest User

Untitled

a guest
Apr 26th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. class AddRandomSlugToReports < ActiveRecord::Migration
  2. def self.up
  3. change_table :reports do |t|
  4. t.string :slug
  5. t.index :slug
  6. end
  7. Report.reset_column_information
  8. Report.all.each do |report|
  9. report.generate_slug!
  10. report.save
  11. end
  12. end
  13.  
  14. def self.down
  15. change_table :reports do |t|
  16. t.remove :slug
  17. t.remove_index :slug
  18. end
  19. end
  20. end
Add Comment
Please, Sign In to add comment