随笔分类 -  ruby

摘要:OpenSSL::Cipher.new application_controller.rb def decrypter(data) key = ENV['ENCRYPTION_KEY'] iv = ENV['ENCRYPTION_IV'] decipher = OpenSSL::Cipher.new 阅读全文
posted @ 2019-08-12 09:06 冰凌花花~ 阅读(794) 评论(0) 推荐(0)
摘要:Missing template api/v2/subjects/fetch_subject, api/base/fetch_subject, application/fetch_subject with {:locale=>[:"zh-CN"], :formats=>[:html], :varia 阅读全文
posted @ 2017-01-23 12:59 冰凌花花~ 阅读(154) 评论(0) 推荐(0)
摘要:#json.id subject.id #json.title subject.title #json.sub_title subject.sub_title #json.categories subject.categories #json.description subject.description #json.status subj... 阅读全文
posted @ 2017-01-23 11:22 冰凌花花~ 阅读(117) 评论(0) 推荐(0)
摘要:dig(key, ...) → objectclick to toggle source Extracts the nested value specified by the sequence of idx objects by calling dig at each step, returning 阅读全文
posted @ 2017-01-22 11:06 冰凌花花~ 阅读(790) 评论(0) 推荐(0)
摘要:执行 打开管理页面就可以看到了所有的任务了 http://localhost:9292/ 可以在sidekiq启动的时候存入任务进程号 可以使用sidekiqctl关闭服务 阅读全文
posted @ 2016-12-22 17:16 冰凌花花~ 阅读(216) 评论(0) 推荐(0)
摘要:http://api.rubyonrails.org/classes/ActionView/Template.html#method-i-local_assigns 阅读全文
posted @ 2016-12-21 13:18 冰凌花花~ 阅读(226) 评论(0) 推荐(0)
摘要:def search @videos = Video.where("videoid LIKE ? or title LIKE ?", "%#{params[:q]}%", "%#{params[:q]}%") render :index end 使用 hash 的写法 def search @videos = Video.where("vi... 阅读全文
posted @ 2016-12-12 13:15 冰凌花花~ 阅读(108) 评论(0) 推荐(0)
摘要:The most interesting addition to Ruby 2.3.0 is the Safe Navigation Operator(&.). A similar operator has been present in C# and Groovy for a long time 阅读全文
posted @ 2016-11-07 11:04 冰凌花花~ 阅读(256) 评论(0) 推荐(0)
摘要:修改后 阅读全文
posted @ 2016-09-20 18:37 冰凌花花~ 阅读(371) 评论(0) 推荐(0)
摘要:原代码 存储的数据格式为 categories: "[\"tv\", \"entertainment\"]", 修改为 存储的数据格式为 categories: " \n- tv\n- comic\n", YAML 序列化后的样子,YAML 的数组相关文档,可看 YAML 的文档:http://ya 阅读全文
posted @ 2016-09-20 11:27 冰凌花花~ 阅读(187) 评论(0) 推荐(0)
摘要:https://gist.github.com/stream7/1069589 关于sequence 字段limit: 2 是两个字节,16 位,2 的 15 次方是 32767 对于多态关联的表 t.integer :subjectable_id 不需要设置limit,因为这个是用来做外键的,存储 阅读全文
posted @ 2016-09-18 11:47 冰凌花花~ 阅读(208) 评论(0) 推荐(0)
摘要:rails enum 阅读全文
posted @ 2016-09-13 14:14 冰凌花花~ 阅读(610) 评论(0) 推荐(0)
摘要:https://github.com/rails/jbuilder 的set!方法重构接口, 因为grape没法使用 jBuilder 的缓存,所以直接用 Rails 写 API (1)多个图片 原来的方法为 精简后为 (2)hints 是一个 hash,遍历 Hash 的文档 http://rub 阅读全文
posted @ 2016-09-12 14:02 冰凌花花~ 阅读(229) 评论(0) 推荐(0)
摘要:最近在处理一个小功能,每个元素可以有多个图片,每个图片的name表示了它是背景图还是海报图, 需要对每个元素的图片name做一个唯一性验证,一个元素不能添加两个海报图, 需要使用的是validates_uniqueness_of http://api.rubyonrails.org/classes/ 阅读全文
posted @ 2016-09-07 11:32 冰凌花花~ 阅读(490) 评论(0) 推荐(0)
摘要:在图片管理里添加了校验方法之后,发现在更新的时候页面不显示校验报错的信息 update!在校验的时候会抛出异常,导致ajax操作中断, 原因是在controller的update方法里加了!,变成了update!(component_params), 去掉后的方法如下 去掉后的log如下 阅读全文
posted @ 2016-09-06 16:25 冰凌花花~ 阅读(344) 评论(0) 推荐(0)
摘要:rails web app页面之间的跳转的时候使用ducument.ready只有在再次加载的时候才生效, 因为rails用了turbolinks, https://github.com/turbolinks/turbolinks/blob/master/README.md#running-java 阅读全文
posted @ 2016-09-01 10:01 冰凌花花~ 阅读(467) 评论(0) 推荐(0)
摘要:在component表里用text类型的字段存储hash数据 (1)新建字段 ,这是migration的内容 (2)controller (3)model (4)_component.html.erb (5)_form.html.erb 参考资料 http://vladexologija.blogs 阅读全文
posted @ 2016-08-31 16:54 冰凌花花~ 阅读(182) 评论(0) 推荐(0)
摘要:When you first started coding, errors were probably the last thing you wanted to see. After all, it’s not a far stretch to associate “error” with “I m 阅读全文
posted @ 2016-05-08 12:07 冰凌花花~ 阅读(217) 评论(0) 推荐(0)
摘要:Often, classes will have shared characteristics with other classes. Rewriting the same methods for each class over and over again can be pretty cumber 阅读全文
posted @ 2016-05-08 10:45 冰凌花花~ 阅读(162) 评论(0) 推荐(0)
摘要:When calling an instance method like withdraw_securely, the syntax generally looks something like this: One would therefore think it’s safe to assume 阅读全文
posted @ 2016-05-07 21:03 冰凌花花~ 阅读(193) 评论(0) 推荐(0)