随笔分类 -  Ruby

Ruby
摘要:Gem离线包安装 项目环境 以 rest-client 为例 本地如果是rails项目环境: ruby '2.7.0' gem 'rails', '~> 6.0.3', '>= 6.0.3.2' 下载gem离线包 下载地址: https://rubygems.org/search?query=res 阅读全文
posted @ 2023-02-28 18:26 HaimaBlog 阅读(678) 评论(0) 推荐(0)
摘要:ruby和glang的md5和sha1加密对比 package main import ( "crypto/md5" "crypto/sha1" "fmt" "io" "io/ioutil" "log" "strings" ) func main() { testMd5OrSha2() } func 阅读全文
posted @ 2022-03-04 15:02 HaimaBlog 阅读(158) 评论(0) 推荐(0)
摘要:安装 gem install rufus-scheduler ruby #!/usr/bin/env ruby require 'rubygems' require 'rufus-scheduler' scheduler = Rufus::Scheduler.new scheduler.every 阅读全文
posted @ 2022-01-28 16:14 HaimaBlog 阅读(204) 评论(0) 推荐(0)
摘要:参考文章: https://www.jianshu.com/p/7ea473097023 安装redis 配置redis 配置sidekiq所依赖的redis位置,必须同时定义sidekiq的server和client config/initializers/sidekiq.rb # 这里的地址和端 阅读全文
posted @ 2021-12-28 14:50 HaimaBlog 阅读(669) 评论(0) 推荐(0)
摘要:后端变量 @namelist 前端解释 var result_json = <%= @namelist.to_json.html_safe %> 阅读全文
posted @ 2021-12-14 15:47 HaimaBlog 阅读(71) 评论(0) 推荐(0)
摘要:ruby执行周期性任务 下面看看怎么将任务写入cron服务。 $ whenever #不带参数的whenever会显示转换程cron任务的代码,不写入cron任务表 $ whenever -w #写入cron任务表,开始执行 $ whenever -c #取消任务 如果要查看cron任务表,也可以使 阅读全文
posted @ 2021-12-02 12:31 HaimaBlog 阅读(104) 评论(0) 推荐(0)
摘要:Gemfile里添加 gem 'byebug' bundle install 在要打断点的地方写 byebug byebug -h #帮助 c 放行,入下走 n 单行调适 q 退出进行 启动异步任务推送work: rails c # 默认为development模式 rails c -e produ 阅读全文
posted @ 2021-11-22 21:50 HaimaBlog 阅读(111) 评论(0) 推荐(0)
摘要:操作xlsx axlsx插件 操作xls spreadsheet插件 阅读全文
posted @ 2021-11-19 17:42 HaimaBlog 阅读(117) 评论(0) 推荐(0)
摘要:参考文章: https://blog.csdn.net/a60919820/article/details/101847890 安装mysql 参考:https://www.cnblogs.com/haima/p/15504670.html 再安装libmysqlclient-dev 和 mysql 阅读全文
posted @ 2021-11-03 17:40 HaimaBlog 阅读(161) 评论(0) 推荐(0)
摘要:https://github.com/rbenv/rbenv https://www.cnblogs.com/yiluhuakai/p/9414730.html https://ruby-china.org/wiki/rbenv-guide 官网: https://rvm.io/rvm/instal 阅读全文
posted @ 2021-11-02 20:10 HaimaBlog 阅读(73) 评论(0) 推荐(0)
摘要:参考: https://www.cnblogs.com/wf0117/p/9080726.html 1.读取csv 文件中读取:一次读入全部(设置headers使 CSV#shift() 以CSV::Row对象返回而不是数组;使 require 'csv' CSV#read() 返回 CSV::Ta 阅读全文
posted @ 2021-09-07 21:31 HaimaBlog 阅读(558) 评论(0) 推荐(0)
摘要:控制器 def index #传给前端展示层当前的id @id = 6 end # http://127.0.0.1:3000/admin/category_statistics/export_table?id=6 def export_table puts "@params > #{params} 阅读全文
posted @ 2021-09-03 15:35 HaimaBlog 阅读(102) 评论(0) 推荐(0)
摘要:参考: https://blog.csdn.net/xing102172/article/details/9163607 For example: h={'a'=>2, 'c'=>1, 'b'=>3} sort 方法: key升序: h.sort { |a, b| a[0]<=>b[0] } [[" 阅读全文
posted @ 2021-08-28 01:37 HaimaBlog 阅读(217) 评论(0) 推荐(0)
摘要:参考: https://www.jianshu.com/p/aef65d0c03a4 阅读全文
posted @ 2021-08-19 21:19 HaimaBlog 阅读(51) 评论(0) 推荐(0)
摘要:参考下面的连接 使用Rails构建JSON-API https://chorder.net/2018/07/31/%E4%BD%BF%E7%94%A8Rails%E6%9E%84%E5%BB%BAJSON-API/ 安装jwt组件 Gemfile里添加 # jwt gem 'jwt' 执行命令: b 阅读全文
posted @ 2021-08-19 14:42 HaimaBlog 阅读(298) 评论(0) 推荐(0)
摘要:控制器文件 app/controllers/api/v1/order_controller.rb def create # 从本地读取 log_dir = File.expand_path(File.join(Rails.root.to_s,'/log/ip04.log')) puts "log_d 阅读全文
posted @ 2021-08-07 10:36 HaimaBlog 阅读(254) 评论(0) 推荐(0)
摘要:文档地址: https://freed.gitee.io/rails-guides/active_record_querying.html 创建 ## 记录日志 Log.create(logtype: 2, email: current_user.email, user_id: current_us 阅读全文
posted @ 2021-08-05 22:45 HaimaBlog 阅读(253) 评论(0) 推荐(0)
摘要:使用Elasticsearch在Rails中进行全文本搜索 参考: https://blog.csdn.net/cunjie3951/article/details/106921108 阅读全文
posted @ 2021-07-31 12:51 HaimaBlog 阅读(52) 评论(0) 推荐(0)
摘要:创建迁移文件 rails g migration add_product_images_index 编写迁移文件 db/migrate/20170119093958_add_product_images_index.rb class AddProductImagesIndex < ActiveRec 阅读全文
posted @ 2021-07-20 07:53 HaimaBlog 阅读(117) 评论(0) 推荐(0)
摘要:Ruby on Rails是一个功能强大的WEB开发框架,在这里我们将会学到一些经常用到的Ruby on Rails内置方法,帮助大家熟练掌握其应用技巧。 Ruby on Rails自动生成文档技巧大讲堂 Ruby代码管理经验分享 Ruby创建构造器技巧分享 Ruby异常处理结构特点介绍 Ruby数 阅读全文
posted @ 2021-07-19 07:53 HaimaBlog 阅读(144) 评论(0) 推荐(0)