class User
def full_name
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
data:text/html, <style type="text/css">#e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div id="e"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("e");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/ruby");</script> |
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
class Area < ActiveRecord::Base | |
acts_as_nested_set :counter_cache => :children_count | |
#Area.rebot(省ID,[市ID]) | |
#Area.rebot(3198,[3213]) or Area.rebot(3198) | |
scope :robot, ->(s,q=[]) { where("parent_id in (?)",q.or(select(:id).where(:parent_id => s))) } | |
[:parent,:root,:province,:city,:district].each do |instance| | |
class_eval <<-EOF,__FILE__,__LINE__ + 1 | |
delegate :name,:to => :#{instance} ,:allow_nil => true,:prefix => true | |
#{next if [:parent].include?(instance)} |
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
class Hash | |
# k = {} | |
# k.create_deeps(*%w(1 2 3 4 5 6 7 8 9 10)) | |
# #=> {"1"=>{"2"=>{"3"=>{"4"=>{"5"=>{"6"=>{"7"=>{"8"=>{"9"=>"10"}}}}}}}}} | |
def create_deeps(*args) | |
self.replace deep_create(*args) | |
end | |
def deep_create(*args) | |
dup.deep_create!(*args) |
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
class Foo | |
include MagicEnum | |
attr_accessor :status | |
enum_attr :status, [ ["Open",0],["Close",1]] | |
end | |
foo = Foo.new | |
foo.status = 1 |
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
/(?<foo>regexp)/ =~ "regexp" | |
foo # => "regexp" |
Ensures that the object/expression is true.
- assert( boolean, [msg] )
Ensures that obj1 == obj2 is true.
- assert_equal( obj1, obj2, [msg] )
Class Name corresponds to
Module included
- db:create creates the database for the current env
- db:create:all creates the databases for all envs
- db:drop drops the database for the current env
- db:drop:all drops the databases for all envs
- db:migrate runs migrations for the current env that have not run yet
- db:migrate:up runs one specific migration
- db:migrate:down rolls back one specific migration
- db:migrate:status shows current migration status
- db:migrate:rollback rolls back the last migration
- db:forward advances the current schema version to the next one
OlderNewer