Skip to content

Instantly share code, notes, and snippets.

@oojikoo-gist
Last active August 29, 2015 14:19
Show Gist options
  • Save oojikoo-gist/22af545a0bf91195cb84 to your computer and use it in GitHub Desktop.
Save oojikoo-gist/22af545a0bf91195cb84 to your computer and use it in GitHub Desktop.
rails: methods dictionary
# 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