Advertisement
Guest User

Untitled

a guest
May 29th, 2015
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. # rails methods
  2.  
  3. # returns column_names arrays
  4. Model.column_names
  5.  
  6. # returns attr_keys arrays
  7. object.attributes.keys
  8.  
  9. # returns attr_keys values
  10. object.attributes.values
  11.  
  12. # set custom table name
  13. class Model < ActiveRecord::Base
  14. self.table_name = "mdels"
  15. end
  16.  
  17. # module for has_one
  18. module Addressable
  19. def self.included(klazz) # klazz is that class object that included this module
  20. klazz.class_eval do
  21. has_one :address
  22. end
  23. end
  24. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement