自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(13)
  • 收藏
  • 关注

原创 git命令

克隆指定分支:git clone -b dev-edmon git@xxx:xxx/xxx.git

2018-12-20 13:20:42 98

原创 ruby中uniq和uniq!的区别

uniq不会改变数组本身,而uniq!会直接修改数组,且uniq如果找到重复元素,则返回去重的数组,否则返回nil(这里比较容易理解错误而踩坑)a = [5,2,2,5,3]a.uniq # [5, 2, 3]p a # [5, 2, 2, 5, 3]a.uniq! # [5, 2, 3]p a # [5, 2, 3]a.uniq! # nilp a # [5, 2, 3]参考:https://

2020-08-13 11:10:28 667

原创 rails has_one 报错

rails has_one 报错在rails的model建立has_one关系时,某些特殊的名称会因为和active record已定义的方法重名而报错:You tried to define an association named transaction on the model TransactionRelation, but this will conflict with a method transaction already defined by Active Record. Please

2020-07-24 15:09:32 148

原创 时差等原因导致Cron定时未执行

如果确认cron语句无误(相同语句尝试每分钟执行是成功的),但是定到具体时间再调整系统时间并不能按时执行:修改时间 && 同步硬件时间 && 重启crondate -s 15:00:50 && hwclock -w && service crond restart...

2019-08-16 14:25:36 395

原创 ruby块和可变参数的使用

假设有以下两个方法需要使用数据库def add(var1,var2,str) "add方法使用数据库"enddef count(var) "count方法使用数据库"end为了方便统一配置,我们用一个hook函数配置数据库信息,之后调用hook函数就自动在执行以上方法前配置好数据库了def before_execute_function_add(var1,var2,str)...

2019-07-04 17:26:35 338

原创 电脑开机秒熄

最近组装一台新的台式,发现各种线都接好之后开机却一秒钟之内熄火,网络上给出的原因包括主板放点,重插内存条。。。。。尝试无果通过查找国外论坛发现了相同的案例:https://www.bleepingcomputer.com/forums/t/687191/computer-shuts-down-immediately-after-pressing-power-button/主板不支持7代CPU...

2019-06-05 18:12:29 290

原创 rails select下拉框

# 两种rails里面的form使用手写下拉框的方式<%= form_for @xxx do |f| <%= f.select :category, [['All', 1], ['Co', 2], ['Bought', 3], ['View', 4], ['Top API', 5]], {}, class:"xxx"%>%><%= select_tag(:o...

2019-03-20 14:10:56 629

转载 rail 在controller里面修改params

参考地址# 传入参数进行secure params处理def trip_params params.require(:trip).permit(:name, :date)end# 然后使用时想要修改参数值def save trip_params[:name] = 'Modifying name in place' #trip_params[:name] 仍然是原来的值en...

2019-02-22 16:18:14 189

原创 rails查询非模型数据表里的数据

假设有辅助表user_names,且UserName不是rails项目中的一个模型,可以用以下方式查询数据:class User_name &lt; ApplicationRecord;end# puts User_name.find_by_sql("select *from names where id&gt;100").firstputs User_name.select("*").wh...

2019-01-15 16:48:29 114

原创 rails 使用关联表的列进行order排序

假设有模型article和模型comments,关系为class Article &amp;lt; ApplicationRecord has_many :comments xxxxend# comments表里面有created_at用来标记评论时间class comments &amp;lt; ApplicationRecord belongs_to :comment xxxxend现...

2019-01-10 11:07:20 672

原创 JavaScript删除csdn广告

F12打开控制台,复制以下代码并回车://删除右边广告var rchild = document.getElementById(&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;quot;para_render_s26&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;quot;);rchild.parentNode.removeChild(rchild);//删除footer广告var footer =

2018-12-29 11:35:53 207

原创 Devise邮件模板路径

以重置密码发送的邮件为例:devise发送邮件的模板在:[项目]/app/views/devise/mailer/reset_password_instructions.html.erb如果此路径下不存在对应的模板则会去默认路径找默认路径是/usr/local/rvm/gems/ruby-2.3.3/gems/[devise版本]/app/views/devise/mailer/reset_...

2018-12-18 15:13:07 321

原创 ruby获取两个日期中间的所有日期

require 'date'date_from = Date.parse('2017-2-28')date_end = Date.parse('2017-10-03')(date_from..date_end).each do |day| puts dayend=begin2017-02-282017-03-012017-03-022017-03-032017-03-0...

2018-10-26 14:31:05 417

空空如也

空空如也

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

TA关注的人

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