自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(15)
  • 资源 (1)
  • 收藏
  • 关注

原创 map

map is another extremely useful Ruby iterator. It helps us map data from one form to another. It will return a new Array containing the result of running the specific block on each element in the coll

2016-04-30 17:29:13 217

原创 each-Select

While Ruby’s each method is useful, it also comes with an awesome extended family of methods that are even more powerful!For the next few examples, we’ll work with a slightly more complex data str

2016-04-30 17:03:17 352

原创 why we use Symbols in Hash

Rather than using Strings as the keys in a Hash, it’s better practice to use Symbols. Symbols are just like Strings except they’re faster and take up less memory. The reason Symbols are so efficie

2016-04-30 14:35:11 300

原创 compact过滤数组中的nil

http://ruby-doc.org/core-2.2.0/Array.html#method-i-compactcompact → new_aryclick to toggle sourceReturns a copy of self with all nil elements removed.[ "a", nil, "b", nil, "c", nil ].compa

2016-04-25 17:47:46 302

原创 invert

http://docs.ruby-lang.org/en/2.0.0/Hash.htmlinvert → new_hashReturns a new hash created by using hsh's values as keys, and the keys as values.h = { "n" => 100, "m" => 100, "y" => 300, "d" => 2

2016-04-25 17:42:41 597

原创 Item 表单页面的 Select2 相关业务逻辑

Select2 插件官网:https://select2.github.io/Select2 初始化说明:代码在 public/javascripts/subchannel_items.js 中的 $("#subchannel_item_showable_id").select2 行。select2 方法中的参数说明:theme:指定 CSS 主题,Bootst

2016-04-25 10:44:00 746

原创 不同版本的name可以重复

- validates :name, presence: true, uniqueness: { conditions: -> { where(:state.ne => 2) } }, length: { maximum: 9 }+ validates :name, presence: true, length: { maximum: 9 }validates :name, presence

2016-04-25 10:30:15 341

原创 @version ||= version

# -*- encoding : utf-8 -*-class InterfaceBaseController ActionController::Base private def set_version version = params[:version] || '1.8.0' ua = params[:ua] || '' @version = if ua

2016-04-21 19:33:22 346

原创 关联表级联删除

Mysql2::Error: Cannot delete or update a parent row: a foreign key constraint fails (`todo_list_development`.`todo_items`, CONSTRAINT `fk_rails_d913ce1c56` FOREIGN KEY (`todo_list_id`) REFERENCES `tod

2016-04-19 09:54:42 1003

原创 clone

all_subchannels.each do |subchannel| new_subchannel = subchannel.clone new_subchannel.version = "1.8.0" new_subchannel.saveend

2016-04-14 16:04:53 190

原创 序列化.to_sym

def showable_paths{ #Filter: cibn_filterlists_path, Video: videos_path, Subject: cibn_special_subjects_path, Star: stars_path} end

2016-04-14 16:04:12 298

原创 git pull --rebase

$ git push bit 1.8-subchannelsTo git@bitbucket.org:cms.git! [rejected] 1.8-subchannels -> 1.8-subchannels (fetch first)error: failed to push some refs to 'git@bitbucket.orgcms.git'hint: See the 'N

2016-04-14 16:02:34 464

原创 previous_changes方法

[27] pry(main)> c = Channel.find 6=> #[28] pry(main)> c.valid?=> true[29] pry(main)>[30] pry(main)>[31] pry(main)> c.has_filter=> "1"[32] pry(main)> c.cid=> "96"[33] pry(main)> c.is_default_

2016-04-08 14:35:12 534

原创 select function in ruby

# TODO: 使用 MySQL 的 FIND_IN_SET,必须过滤掉逗号分割符之间的空格 # http://dev.mysql.com/doc/refman/5.7/en/string-functions.html#function_find-in-set custom_subjects = SpecialSubject.where('state = ? AND pid

2016-04-08 14:04:41 246

原创 different between unicorn / unicorn_rails

$ unicorn_rails -hUsage: unicorn_rails [ruby options] [unicorn_rails options] [rackup config file]Ruby options: -e, --eval LINE evaluate a LINE of code -d, --debug set debu

2016-04-05 11:09:19 573

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除