Last active
August 29, 2015 14:19
-
-
Save oojikoo-gist/22af545a0bf91195cb84 to your computer and use it in GitHub Desktop.
rails: methods dictionary
This file contains hidden or 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
# rails methods | |
# returns column_names arrays | |
Model.column_names | |
# returns attr_keys arrays | |
object.attributes.keys | |
# returns attr_keys values | |
object.attributes.values | |
# set custom table name | |
class Model < ActiveRecord::Base | |
self.table_name = "mdels" | |
end | |
# module for has_one | |
module Addressable | |
def self.included(klazz) # klazz is that class object that included this module | |
klazz.class_eval do | |
has_one :address | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment