-
rails destroy scaffold注意事项
所属栏目:[百科] 日期:2020-12-17 热度:62
删除scaffold前应该先运行 rake db:rollback 以确保数据库恢复到先前的状态,要不然删除scaffold的时候把migration一并删除,再 rake db:rollback 就太晚了[详细]
-
gem安装时出现 undefined method `size' for nil:NilClass (
所属栏目:[百科] 日期:2020-12-17 热度:86
# gem env 得到gem的PATH路径,比如 ? - GEM PATHS: ???? - /usr/local/ruby/lib/ruby/gems/2.1.0 ???? - /home/vagrant/.gem/ruby/2.1.0 将其下的cache目录删除,再次执行gem安装的时候就不会出错了[详细]
-
rails server运行多个实例
所属栏目:[百科] 日期:2020-12-17 热度:186
举个例子,在不同的窗口分别运行下面两行代码: rails s -b 192.168.0.68 rails s -b 192.168.0.68 -p 3001 -P tmp/pids/pid2.pid 即可运行不同的实例,各用各的端口,各用各的pid文件,访问两个不同的端口地址的时候,日志互不影响[详细]
-
提高rails new时bundle install运行速度
所属栏目:[百科] 日期:2020-12-17 热度:142
rails new my_app --skip-bundle cd my_app bundle install --local 转自:http://rubyer.me/blog/941/[详细]
-
ruby调用imagemagick实现验证码
所属栏目:[百科] 日期:2020-12-17 热度:146
效果不甚理想 #coding: utf-8`convert -draw "line 5,35 95,5" -pointsize 50 -font ~/Desktop/wqy.ttc label:睁大挂跟 ~/Desktop/test.png` 上面的代码只能生成规则的字体,并且干扰线很细,不能设置变粗,暂时先调用python实现[详细]
-
ruby字符串的encoding,force_encoding,encode,encode!转码(编码
所属栏目:[百科] 日期:2020-12-17 热度:162
ruby1.9开始对字符串编码支持已经比较完善,我们可以直接通过使用String类的实例方法 encoding , force_encoding , encode , encode! 进行相关的编码操作。 encoding ruby1.9中为每个字符串对象增加了encoding信息 1.9.3p392 :001 '我还是不懂'.encoding = #[详细]
-
开发rails用rack-mini-profiler这个gem看console信息很方便
所属栏目:[百科] 日期:2020-12-17 热度:110
可以看到当前页面及每个资源的加载时间,还可以看当前页面执行的sql语句,再也不用盯着console看运行日志了。[详细]
-
ruby中用ancestor取得类的祖先链
所属栏目:[百科] 日期:2020-12-17 热度:62
[4] pry(main) Array.ancestors= [Array,Enumerable,Object,PP::ObjectMixin,Kernel,BasicObject][5] pry(main) String.ancestors= [String,Comparable,BasicObject][详细]
-
rails4.2.0和spree3.0和dotenv-rails冲突的问题
所属栏目:[百科] 日期:2020-12-17 热度:144
默认安装的dotenv-rails的版本是2.0.1,运行时出现错误: /Users/gs/.rvm/gems/ruby-2.2.1@rails420/gems/railties-4.2.0/lib/rails/railtie/configuration.rb:95:in `method_missing': undefined method `eager_load_paths' for #Rails::Railtie::Configura[详细]
-
rails不能在model中使用type作为字段名的解决办法
所属栏目:[百科] 日期:2020-12-17 热度:104
使用type作为字段名会出现这个错误: ActiveRecord::SubclassNotFound: The single-table inheritance mechanism failed to locate the subclass: 'xxxx'. This error is raised because the column 'type' is reserved for storing the class in case of in[详细]
-
ruby一行定义md5、md5file函数
所属栏目:[百科] 日期:2020-12-17 热度:120
require 'digest/md5'; def md5(str); Digest::MD5.hexdigest(str); end; def md5file(str); Digest::MD5.hexdigest(File.open(str).read); end 在pry中用的时候很方便[详细]
-
textmate2保存文件时自动删除行尾空格
所属栏目:[百科] 日期:2020-12-17 热度:100
默认textmate2是没有这个功能的,不过可以通过Bundles开启,开启方法: 1、点击菜单中的Bundles,然后 Edit Bundles QQ20190727-0@2x.png (上传于2019-07-27 03:00:38) 2、在弹出窗口中,依次点击 Text - Menu Actions - Converting / Stripping - Remove Tr[详细]
-
passenger设置起始进程数
所属栏目:[百科] 日期:2020-12-17 热度:199
http { ? ?passenger_root /usr/local/lib/ruby/gems/2.3.0/gems/passenger-5.0.30; ? ?passenger_ruby /usr/local/bin/ruby; ? ? passenger_min_instances 3; ??? //此处设置起始进程数为3 ? ?passenger_pre_start http://blog.bccn.net/sessions/seccode_c[详细]
-
基于纯 ruby 的 XML/HTML 解析器,可替代 nokogiri
所属栏目:[百科] 日期:2020-12-17 热度:91
https://gitlab.com/yorickpeterse/oga[详细]
-
语言是思维的记号
所属栏目:[百科] 日期:2020-12-17 热度:163
选一个好看点的记号,便于梳理思维,有利于身心健康。 乱糟糟的记号把人的思维都带乱了,以其昏昏使人昭昭,@php -------------------------------- 作者在 2020-05-20 20:07:46 补充以下内容 -------------------------------- 7-71-carat-burma-ruby-and-p[详细]
-
capistrano列出所有命令(task)
所属栏目:[百科] 日期:2020-12-17 热度:144
cap -T[详细]
-
搭建完spree commerce以后需要运行的3个命令
所属栏目:[百科] 日期:2020-12-17 热度:123
bundle exec rake db:migrate bundle exec rake db:seed bundle exec rake spree_sample:load[详细]
-
Rails直接更新字段用where ... update_all ...或update_column
所属栏目:[百科] 日期:2020-12-17 热度:156
不查询数据记录,直接更改 Category.where(id: category_id).update_all(articles_count: articles_count) -------------------------------- 作者在 2019-08-23 19:21:10 补充以下内容 -------------------------------- 也可以直接使用update_column @cate[详细]
-
ruby类获取所有非继承方法的方法
所属栏目:[百科] 日期:2020-12-17 热度:88
Model.instance_methods(false) 如果获取包含继承的方法,后面的参数则改为 true[详细]
-
rails清理assets缓存的方法
所属栏目:[百科] 日期:2020-12-17 热度:128
刚才development环境下 sass 中的?image_url 失效了,运行下面的命令清空缓存解决: rake assets:clobber[详细]
-
ruby生成随机字串
所属栏目:[百科] 日期:2020-12-17 热度:102
(0...50).map { ('a'..'z').to_a[rand(26)] }.join[详细]
-
用docker部署rails应用以后要把log和tmp的权限设置为777
所属栏目:[百科] 日期:2020-12-17 热度:133
cd到rails的目录,执行 chmod 777 -R log chmod 777 -R tmp -------------------------------- 作者在 2019-05-28 18:36:39 补充以下内容 -------------------------------- 也可以写在一行: chmod 777 -R log/ tmp/[详细]
-
rvm全局(global)安装gem
所属栏目:[百科] 日期:2020-12-17 热度:185
rvm 2.2.1@global do gem install phantomjs[详细]
-
解决ruby内核参考离线版js文件的引用问题
所属栏目:[百科] 日期:2020-12-17 热度:94
官方的离线版默认是放在根目录的,所以js引用都是这种形式: script src=" / js/extra.js"/script 注意红色的反斜线,这样如果不是放在根目录,那么就会出现js引用的错误。 废话少说,用一段ruby代码即可解决: files = `ag 'src="/js' -l`.split("n")files[详细]
-
ruby遍历文件夹
所属栏目:[百科] 日期:2020-12-17 热度:65
已经不需要自己写递归了,新版ruby直接提供了Find模块 require?'find' Find.find('./')?do?|path| ??puts?path end[详细]