Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. class FixHogeTables < ActiveRecord::Migration[5.1]
  2. def change
  3. table(:hoges).where(type: 'bar').each do |hoge|
  4. ...
  5. end
  6. end
  7.  
  8. def table(name)
  9. result = Class.new(ActiveRecord::Base) do
  10. self.table_name = name
  11. self.inheritance_column = :_dummy_column
  12. end
  13. result.reset_column_information
  14. result
  15. end
  16. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement