Ruby on Rails errors:

(新手期)

rails 自动化部署教程

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 rails binstub at ./bin/rails that

should be used instead of the Bundler-generated rails binstub.

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的更多相关文章

  1. 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 ...

  2. Ruby on Rails创始人DHH谈如何进行混合移动APP开发

    混合型APP兼具原生型APP软件良好用户交互体验的优势和网页型APP软件跨平台开发的优势,并且其开发成本和网页型APP软件接近,其开发效率也远高于原生型APP软件.混合型APP已经被众多企业所认可.最 ...

  3. ubuntu 14.04中安装 ruby on rails 环境

    环境:在win7 上Vmware虚拟机环境中安装的ubuntu 14.04 1. bundle install 时,报json错误可以看出是在安装nokogiri时遇到了问题,此时执行 sudo ap ...

  4. [Ting's笔记Day4]将Ruby on Rails项目部署到Heroku

    今天想笔记的是把自己写的Ruby on Rails项目部署(Deploy)到Heroku! Heroku是Salesforce公司旗下的云端服务商,支持多种程序语言像是Ruby,PHP,Python等 ...

  5. Ruby on Rails Tutorial 第2版 学习笔记

    Ruby on Rails Tutorial 第2版 在线阅读:http://railstutorial-china.org/ 英文版:http://ruby.railstutorial.org/ru ...

  6. ubuntu 14.04中安装 ruby on rails 环境(填坑版) 呕血推荐

    环境:在win7 上Vmware虚拟机环境中安装的ubuntu 14.04 开发相关: ruby 2.2.0 rails 4.2.0 sublime text 3 本文说明:所有的命令均在$ 之后,若 ...

  7. Linux超快速安装Ruby on Rails

    Linux超快速安装Ruby on Rails 时间 2014-11-25 11:45:11 Flincllck Talk 原文  http://www.flincllck.com/quick-ins ...

  8. 管理不同版本ruby和rails的利器——rvm

    近年来,ruby on rails逐渐火了起来,我想各位码农早就耳闻,特别是那些做B/S项目的童鞋,早就想跃跃一试了. 笔者也是初次接触ruby on rails ,我想,对于初学者来说,最好的学习方 ...

  9. ruby on rails on windows

    这次想系统学会rails,最终目标是将redmine改造成顺手的工具,主要的手段就是开发redmine插件.虽然网上都推荐使用类Unix系统,可手头只有win7系统,就安装了. 难免会遇到这样那样的问 ...

  10. win8平台下Ruby on Rails的第一个web应用

    最近在做一个网站web前端的前期开发,老板要求用Ruby on Rails搭建部署开发环境,上网搜之,发现整个搭建流程比较坑爹,于是用了一款集成软件Bitnami Ruby Stack一键安装到我的w ...

随机推荐

  1. 树莓派Raspbian系统密码

    树莓派Raspbian系统密码 树莓派Raspbian系统默认登录用户名为pi,该账户默认密码是raspberry(可在raspi-config中修改). 树莓派的Raspbian系统root用户默认 ...

  2. 前端项目中公共方法汇总utils.js

    目录 判断手机类型IOS Android 格式化金钱 金钱字符串变回数字 用aa替换中文 并返回 去除文件后缀,得到文件名称(不带后缀) 获取浏览器类型(名称) post方式下载文件流 动态设置img ...

  3. Hibernate 5.x 生成 SessionFactory 源码跟踪分析

    我们要使用 Hibernate 的功能,首先需要读取 Hibernate 的配置文件,根据配置启动 Hibernate ,然后创建 SessionFactory. 创建 SessionFactory ...

  4. Oracle ERP 库存管理(业务流程 核心流程)

    库存核心业务 库存管理的核心是对货物本身的管理,是对货物的数量与相关属性的管理,目的是为销售与采购服务,确保合理的库存保有量,处理库存分类帐目与进出流水帐,以单据的形式基本涵盖仓库的各种进出库业务. ...

  5. JVM 理论基础目录(待更新,系列完全写完后会统一整理好)

    参考文档: [1] Java 虚拟机规范(Java SE 8版) [2] 深入理解 Java 虚拟机: JVM 高级特性与最佳实践 周志明 本系列的更新快慢全部随意,介意者请海涵. 一 .JVM 入门 ...

  6. IDEA 创建类是自动添加注释和创建方法时快速添加注释

    1.创建类是自动添加注释 /*** @Author: chiyl* @DateTime: ${DATE} ${TIME}* @Description: TODO*/2. 创建方法时快速添加注释2.1 ...

  7. Odoo字段类型详解

    转载请注明原文地址:https://www.cnblogs.com/ygj0930/p/10826099.html   一:基本字段类型 Binary:二进制类型,用于保存图片.视频.文件.附件等,在 ...

  8. lua redis接口 (在ubuntu16.04 环境下配置lua-redis开发环境)

    目前成功的lua版本是5.1, 根据网络上的资料显示 lua5.1能够支持 lua-socket 安装lua及相关软件: #安装lua5. #安装lua-socketxiangg sudo apt i ...

  9. Istio技术与实践06:史上最全!Istio安装参数介绍

    一. CertManage Istio-1.0版本新加入的组件,利用ACME为Istio签发证书 Key Default Value Description certmanager.enabled T ...

  10. HDU4183 Pahom on Water(来回走最大流,一个点只经过一次)

    题意: 有n个圆,每个圆的中心和半径和一个频率都给定,只有一个频率最高的789为紫色,只有一个最低的400为红色,规则如下: 1.当两个圆严格相交时,且人是从红色到紫色的方向运动时可以由低频率向高频率 ...