搬运一下:https://stackoverflow.com/questions/38663706/loaderror-could-not-load-the-listen-gem-rails-5 解决办法: 1. Gemfile 中的 development group中的listen gem不要删掉 2. 或者 见参考文章,把配置文件中的 watch项目删掉(没用过)
Rails Sendemails,content,body,attachment附件
refer to: https://api.rubyonrails.org/classes/ActionMailer/Base.html class NotifierMailer < ApplicationMailer def welcome(recipient) attachments["free_book.pdf"] = File.read("path/to...
Caddy Caddy的基本用法和使用railsassets
caddy: 一种类似于轻量nginx吧 非常好玩,文件夹中: caddy 命令, CaddyFile 配置CaddyFile即可。 然后 ./caddy restart 就行。 等同于nginx -s reload Caddy 与rails配合使用 rails 正常启动: bundle bundle exec rails webpacker:install bundle ex...
Rails Activerecord的模型中,不能用hash作为列名字
如题。否则会报错 Type error,  can not convert String to Integer 
Javascript Axios会发送options请求?
参考;https://stackoverflow.com/questions/14540065/how-do-you-route-options-in-rails/70967131#70967131 https://stackoverflow.com/questions/32223675/getting-actioncontrollerroutingerror-no-route-matche...
Rails 新版rails需要使用webpackserver以及如何新增图片,js,css等静态资源
refer to: https://guides.rubyonrails.org/webpacker.html 新版rails出现了,之前没有用过webpack server,  现在发现它的功能很强大,可以在 rails中直接使用 node module.  不需要browserfy了. webpacker的使用 1. bundle exec rai...
Vue Unreachablecodeafterreturnstatement
这个问题是在vue2 -> vue3的时候出现的。(其实在vue2的时候就出现了) 问题显示在browser console中: 可以看到,最下面一行字就是,对应的是 app.js :  46 2   , 表示是46行,第2列有问题。 点击一下(忘记了具体如何点击的了),会提示我们,在app.js 的3903行,有问题 (注意行数变了) 没有截到图。&...
Elixir Phoenix3.使用ecto来操作数据库
时隔好几年,记录一下吧 elixir的增删改查跟rails的几乎一样。唯一不同的是elixir喜欢用postgres 参考:https://hexdocs.pm/ecto/getting-started.html#adding-ecto-to-an-application 前期准备 1. 创建一个mix项目  mix new test_ecto --sup $ mix new t...
Rails Emailname+address,
refer to: https://stackoverflow.com/questions/957422/rails-actionmailer-format-sender-and-recipient-name-email-address require 'mail' address = Mail::Address.new email # ex: "[email protected]"...
Elixir 常见的语法汇总 奇怪的语法
打印某个变量 IO.puts inspect(var)  |<  管道操作符 , 默认传入第一个参数 result = a |< func1 |< func2 等同于: temp1 = func1 a result = func2 temp1 后者的代码更加容易调试一些 %{}   定义一个hash, &...
Ruby 读取远程的文件open Uriuri.open
注意: 该文件名称不要带有中文,否则需要escape + def read_remote_file url + require 'open-uri' + return URI.open(url).read + end 如果想转义的话,建议只对file-name做转义.不要对 http:// 转义,否则无法被URI.open 读取 参考:https://st...
Ruby 关于ethereum的相关资源(主要是abi哈哈)
最近这里了解的比较多,说一下几个gem: ruby-eth: 挺好的。 就是作者有些保守,不太愿意merge ethereum.rb  不咋地,给它这个评价的主要原因是他基本不支持RPC的 payable/nonpayable调用,只支持有限的 view/pure方法调用。 宝藏资源;(早点用它好了) ruby-ethereum   https://github...
Blockchain Ruby Stringtohextoascii,pack(h*),unpack(h*)
梦回大学 计算机组成原理: bit  最小单位, 0 , 1 组成 , 比特。 byte = 8 bit , 字节。       a , b, c  等是一个字节,  汉字是两个字节 例如,字母a , 在ascii 表中,对应十进制的 97, 16进制的61, 那么 0x61 转换成 二进制,就是&#...
Rails Rails6rails:webpacker::manifest::missingentryerrorinhome#index
refer to: https://stackoverflow.com/questions/54113179/rails-webpackermanifestmissingentryerror-in-homeindex bundle exec rails webpacker:install 同时参考: https://stackoverflow.com/questions/...
Ruby 与nodejs中的buffer等同的ruby语句
我把答案放在了 https://stackoverflow.com/questions/70660339/what-is-the-equivalent-of-nodejs-buffer-in-ruby Buffer.from("abc") 这个会返回一个数组, 例如  [22,23,24] , 分别对应字母  a,b,c Buffer.from("0x01a2", "he...
Rails 让model显示validation错误信息
refer to: https://stackoverflow.com/questions/31806431/rails-validation-knowing-which-field-is-invalid product.valid? # => run validation callbacks, 这个方法一定要调用,否则不会展示下面的内容 product.errors...
Blockchain 使用ethereum.rb初体验和在fujitestnetwork上的踩坑经历
安装, Gemfile: gem 'ethereum.rb'   # 这个仅支持 2.x, 不支持 ruby 3 # 想要支持ruby 3, 就用这个,不过由于 gem 'eth' 目前不支持ruby 3, 所以暂时不建议使用。否则无法发送txgem 'ethereum.rb', :git => "https://github.com/EthWorks/ether...
中老铁路开通有感
ps. 什么情况,一发出来,我的后端进程就挂了?? 看到中老铁路开通,突然有想法,看看外网的评论。 结果发现youtube上搜索 rails china lao, 第二条随便点进去, https://www.youtube.com/watch?v=X4T_K4WWkvg 发现内容是: 1. 铁路开通 2. 老挝有好多好多债务,这个国家尚有好多好多穷人。 看看,敌人到处都是。 dw.com&#...
Rails Belongs_to在最新版本默认是required
refer to: https://www.bigbinary.com/blog/rails-5-makes-belong-to-association-required-by-default 在目前的版本中(貌似 >= Rails 5? ) 只要你写了belongs_to , 那么默认该列就是必须的. 例如 class Apple belongs_to :fruit ...
Ruby Csv读写文件csvreadwritefile
无语了,最近总遇到这个操作。发现自己从来没记录过。 所以写一下吧。 def save_to_csv(csv) CSV.open("C:/ruby/logs.csv", "w") do |row| row << %w[name location dishes time] end end def self.read_from_csv(cs...