ruby-on-rails-BUG
Ruby on Rails errors:
(新手期)
Q1: rvm 无法使用
$ rvm use 1.9.3 --default
RVM is not a function, selecting rubies with 'rvm use ...' will not work.
You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash --login` as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for an example.
使用:
source ~/.rvm/scripts/rvm
或者:
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"' >>~/.bashrc
source ~/.bashrc
Q2: bundle install httpError
run bundle install
The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
Fetching source index from https://rubygems.org/
Retrying fetcher due to error (2/4): Bundler::HTTPError Could not fetch specs from https://rubygems.org/
Retrying fetcher due to error (3/4): Bundler::HTTPError Could not fetch specs from https://rubygems.org/
Retrying fetcher due to error (4/4): Bundler::HTTPError Could not fetch specs from https://rubygems.org
gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/
gem sources -l
gem install rails #如果装rails时失败,就需要重装
#rails 项目需要使用Gemfile 和 Bundle 我们可以用 Bundler 的 Gem 源代码镜像命令。
bundle config mirror.https://rubygems.org https://gems.ruby-china.org
#这样你不用改你的 Gemfile 的 source
参考链接:ruby-china镜像站 快如闪电!
Q3: 生产秘钥 rails4 rails5 不同
ArgumentError: Missing `secret_key_base` for 'production' environment, set this string with `rails credentials:edit`
需要添加生产密钥
在rails4 中这个密钥是通过 rake secret RAILS_ENV=production 创建后放到服务器端的/home/xxx/your_web_app/shared/config/secrets.yml中的,而在rails5中改成了master.key ,使用时需要在本地的/home/xxx/your_web_app/config/deploy.rb 的:link_file手动添加 ‘config/master.key’
如:
# Default value for :linked_files is []
append :linked_files, "config/database.yml", "config/master.key"
Q4: rake aborted!
$ sudo rake secret --trace
rake aborted!
LoadError: cannot load such file -- bundler/setup
这一个可以尝试提权,用root权限运行
Beginning in Rails 4, Rails ships with a
railsbinstub at ./bin/rails that
should be used instead of the Bundler-generatedrailsbinstub.
Q5: The page you were looking for doesn't exist.
The page you were looking for doesn't exist.
You may have mistyped the address or the page may have moved.
本地测试可以,远程服务器不行.检查了一下,路由有问题,处理好远程仓库的代码(因为服务器上应该是从远程仓库上拉取代码的)
Q6: 下拉菜单无法下拉 (使用bootstrap)
下拉菜单无法下拉 (使用bootstrap)
这个功能需要js支持,所以需要包含必要的js库,在/app/assert/javascript/application.js里面添加
//= require jquery
Q7:.... ? ..... : .....
syntax error, unexpected ';' : expecting keyword_end ...cost?BCrypt::Engine::MIN_COST : BCrypt::Engine.cost
这是一个.... ? ..... : ..... 的表达式,居然没有发现,因此中间的问号与前面的判断条件需要有一个空格隔开。
Q8: 开放stmp服务的25端口
F, [2018-09-06T20:33:15.955037 #21413] FATAL -- : [bdf765fc-3c26-4d8f-87be-c5357887f443] ActionView::Template::Error (Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true):
F, [2018-09-06T20:33:15.955131 #21413] FATAL -- : [bdf765fc-3c26-4d8f-87be-c5357887f443] 3: <p>
[bdf765fc-3c26-4d8f-87be-c5357887f443] 4: Welcome to the Sample App! Click on the link below to activate your account:
[bdf765fc-3c26-4d8f-87be-c5357887f443] 5: </p>
[bdf765fc-3c26-4d8f-87be-c5357887f443] 6: <%= link_to "Activate", edit_account_activation_url(@user.activation_token,
[bdf765fc-3c26-4d8f-87be-c5357887f443] 7: email: @user.email) %>
F, [2018-09-06T20:33:15.955158 #21413] FATAL -- : [bdf765fc-3c26-4d8f-87be-c5357887f443]
F, [2018-09-06T20:33:15.955180 #21413] FATAL -- : [bdf765fc-3c26-4d8f-87be-c5357887f443] app/views/user_mailer/account_activation.html.erb:6:in `_app_views_user_mailer_account_activation_html_erb__374929091__625207508'
[bdf765fc-3c26-4d8f-87be-c5357887f443] app/mailers/user_mailer.rb:11:in `account_activation'
[bdf765fc-3c26-4d8f-87be-c5357887f443] app/models/user.rb:48:in `send_activation_email'
[bdf765fc-3c26-4d8f-87be-c5357887f443] app/controllers/users_controller.rb:18:in `create'
首先是我看的教程没有配置邮件服务器的主机host
然而配置完成后又出现内网连接超时的问题,
I, [2018-10-07T23:58:53.103195 #26716] INFO -- : [084c0592-31a4-492c-8686-9cac1b6d2ead] Completed 500 Internal Server Error in 30173ms (ActiveRecord: 7.9ms)
F, [2018-10-07T23:58:53.104096 #26716] FATAL -- : [084c0592-31a4-492c-8686-9cac1b6d2ead]
F, [2018-10-07T23:58:53.104154 #26716] FATAL -- : [084c0592-31a4-492c-8686-9cac1b6d2ead] Net::OpenTimeout (execution expired):
F, [2018-10-07T23:58:53.104187 #26716] FATAL -- : [084c0592-31a4-492c-8686-9cac1b6d2ead]
F, [2018-10-07T23:58:53.104220 #26716] FATAL -- : [084c0592-31a4-492c-8686-9cac1b6d2ead] app/models/user.rb:48:in `send_activation_email'
[084c0592-31a4-492c-8686-9cac1b6d2ead] app/controllers/users_controller.rb:18:in `create'
结果发现是:腾讯云封禁了stmp服务的25端口,so。。工单申请解禁之后就可以正确发送激活的邮箱了。
Q7: 服务器端运维
如何在服务器端增删model对象的属性
在current文件夹下运行 rails console prodution才能正常访问生产环境下的数据信息
因为模型的文件model/在当前项目文件夹是没有文件的,即便rails可以运行,他也找不到model对象就会出现:
irb(main):001:0> User.first
Traceback (most recent call last):
1: from (irb):1
NameError (uninitialized constant User)
另外需要注意的是,如果本地用的mysql和远程使用的mysql密码不一样的话,,database.yml的配置也要不一样
服务器端的用户模型已经有reset_at 属性,使用的迁移肯定有问题
要注意旧的时间戳的迁移,在已经执行过迁移之后重新使用db:migrate是没有效果的,除非db:rollback之后才有效果,想要对数据库做新的增删,需要建立新的迁移文档d
本地测试非常非常重要啊小老弟
所以别在瞎提交本地分支到服务器进行部署,弄错了,麻烦得一匹
Q9: 科学计算环境
对了不要别的什么科学计算环境下运行rails虚拟环境
其实就是anaconda,会触发LoadError
Q10: 测试固件
测试失败 之 固件错误 显示nil
解决方法: 在test/fixtures/xxx.yml 中添加所需要的测试固件
'nil' is not an ActiveModel-compatible object. It must implement :to_partial_path.
view的变量是nil ,所以无法渲染界面
解决: 检查对应的controller 中是否定义了这个变量
Q11: Gemfile与本地的包版本不同
/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.16.2/lib/bundler/runtime.rb:313:in `check_for_activated_spec!': You have already activated i18n 1.1.1, but your Gemfile requires i18n 1.1.0. Prepending `bundle exec` to your command may solve this. (Gem::LoadError)
这是当前激活的包和Gemfile中要求的不一样,可以更改Gemfile,也可以运行bundle update重新配置包
ruby-on-rails-BUG的更多相关文章
- 10 steps to get Ruby on Rails running on Windows with IIS FastCGI- 摘自网络
Since the original tech preview release of FastCGI last year, we've been seeing a lot of requests fo ...
- Ruby on Rails创始人DHH谈如何进行混合移动APP开发
混合型APP兼具原生型APP软件良好用户交互体验的优势和网页型APP软件跨平台开发的优势,并且其开发成本和网页型APP软件接近,其开发效率也远高于原生型APP软件.混合型APP已经被众多企业所认可.最 ...
- ubuntu 14.04中安装 ruby on rails 环境
环境:在win7 上Vmware虚拟机环境中安装的ubuntu 14.04 1. bundle install 时,报json错误可以看出是在安装nokogiri时遇到了问题,此时执行 sudo ap ...
- [Ting's笔记Day4]将Ruby on Rails项目部署到Heroku
今天想笔记的是把自己写的Ruby on Rails项目部署(Deploy)到Heroku! Heroku是Salesforce公司旗下的云端服务商,支持多种程序语言像是Ruby,PHP,Python等 ...
- Ruby on Rails Tutorial 第2版 学习笔记
Ruby on Rails Tutorial 第2版 在线阅读:http://railstutorial-china.org/ 英文版:http://ruby.railstutorial.org/ru ...
- ubuntu 14.04中安装 ruby on rails 环境(填坑版) 呕血推荐
环境:在win7 上Vmware虚拟机环境中安装的ubuntu 14.04 开发相关: ruby 2.2.0 rails 4.2.0 sublime text 3 本文说明:所有的命令均在$ 之后,若 ...
- Linux超快速安装Ruby on Rails
Linux超快速安装Ruby on Rails 时间 2014-11-25 11:45:11 Flincllck Talk 原文 http://www.flincllck.com/quick-ins ...
- 管理不同版本ruby和rails的利器——rvm
近年来,ruby on rails逐渐火了起来,我想各位码农早就耳闻,特别是那些做B/S项目的童鞋,早就想跃跃一试了. 笔者也是初次接触ruby on rails ,我想,对于初学者来说,最好的学习方 ...
- ruby on rails on windows
这次想系统学会rails,最终目标是将redmine改造成顺手的工具,主要的手段就是开发redmine插件.虽然网上都推荐使用类Unix系统,可手头只有win7系统,就安装了. 难免会遇到这样那样的问 ...
- win8平台下Ruby on Rails的第一个web应用
最近在做一个网站web前端的前期开发,老板要求用Ruby on Rails搭建部署开发环境,上网搜之,发现整个搭建流程比较坑爹,于是用了一款集成软件Bitnami Ruby Stack一键安装到我的w ...
随机推荐
- Matlab访问者模式
访问者(Visitor)模式的定义:将作用于某种数据结构中的各元素的操作分离出来封装成独立的类,使其在不改变数据结构的前提下可以添加作用于这些元素的新的操作,为数据结构中的每个元素提供多种访问方式.它 ...
- idea注释类,方法
1.添加类注释:file-settings-file and code Templates-Class #if (${PACKAGE_NAME} && ${PACKAGE_NAME} ...
- Laravel 实现前后台用户分离登录
在很多时候,我们需要前台和后台进行不同的登录操作,以限制用户权限,现在用 Laravel 实现这个需求. 前戏 一.获取 Laravel 这个在文档中都有说明的,也比较简单,可以使用 composer ...
- 【Spring Boot】Spring Boot之使用Alibaba Cloud Toolkit(Idea插件)本地一键部署Spring Boot项目到远程服务器
一.Alibaba Cloud Toolkit(Idea插件)的安装 1)Alibaba Cloud Toolkit 介绍 Cloud Toolkit 是本地 IDE 插件,帮助开发者更高效地开发.测 ...
- CentOS6.7搭建部署DHCP服务 (详解主配置文件)
DHCP服务 dhcp:动态主机配置协议.从bootp演变而来,引进了租约.续租功能,成为了现在的DHCP. 需要就分配,不需要就回收. 工作过程: 1.当获得地址是,有租约期限,当你关机时,IP地址 ...
- python生成测试报告HTMLTestRunner时报错ValueError: write to closed file的解决办法
使用HTMLTestRunner时出现了以下问题: self.stream.write(output.encode('utf8')) ValueError: write to closed file ...
- NLP文本分类方法汇总
模型: FastText TextCNN TextRNN RCNN 分层注意网络(Hierarchical Attention Network) 具有注意的seq2seq模型(seq2seq with ...
- javascript学习3、数据类型、数据类型转换、运算符
数据类型包括:基本数据类型和引用数据类型 基本数据类型指的是简单的数据段,引用数据类型指的是有多个值构成的对象. 当我们把变量赋值给一个变量时,解析器首先要确认的就是这个值是基本类型值还是引用类型值 ...
- destoon开发笔记-JQ+JS实现倒计时功能
页面代码 <div class="time " class="" id="onBidtime125" pid="125&qu ...
- Hive元数据配置到MySql
1 驱动拷贝 1.在/opt/software/mysql-libs目录下解压mysql-connector-java-5.1.27.tar.gz驱动包 [root@hadoop102 mysql-l ...