Advertisement
Guest User

Untitled

a guest
Dec 7th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. class User < ActiveRecord::Base
  2. class_attribute :columns
  3. def self.columns
  4. @columns ||= [];
  5. end
  6.  
  7. def self.column(name, sql_type = nil, default = nil, null = true)
  8. columns << ActiveRecord::ConnectionAdapters::Column.new(
  9. name.to_s,
  10. default,
  11. sql_type.to_s,
  12. null
  13. )
  14. end
  15.  
  16. column :name, :text
  17. column :country_id, :integer
  18. belongs_to :country
  19. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement