(新手期)javascript
rails 自动化部署教程html
$ 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.
使用:java
source ~/.rvm/scripts/rvm
或者:mysql
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"' >>~/.bashrc source ~/.bashrc
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
bundle config mirror.https://rubygems.org https://gems.ruby-china.orgjquery
```web
参考连接:ruby-china镜像站 快如闪电!sql
ArgumentError: Missing `secret_key_base` for 'production' environment, set this string with `rails credentials:edit`
须要添加生产密钥shell
在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’数据库
如:bootstrap
# Default value for :linked_files is [] append :linked_files, "config/database.yml", "config/master.key"
$ 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-generatedrails
binstub.
The page you were looking for doesn't exist. You may have mistyped the address or the page may have moved.
本地测试能够,远程服务器不行.检查了一下,路由有问题,处理好远程仓库的代码(由于服务器上应该是从远程仓库上拉取代码的)
下拉菜单没法下拉 (使用bootstrap)
这个功能须要js支持,因此须要包含必要的js库,在/app/assert/javascript/application.js里面添加
//= require jquery
syntax error, unexpected ';' : expecting keyword_end ...cost?BCrypt::Engine::MIN_COST : BCrypt::Engine.cost
这是一个.... ? ..... : ..... 的表达式,竟然没有发现,所以中间的问号与前面的判断条件须要有一个空格隔开。
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。。工单申请解禁以后就能够正确发送激活的邮箱了。
如何在服务器端增删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
本地测试很是很是重要啊小老弟
因此别在瞎提交本地分支到服务器进行部署,弄错了,麻烦得一匹
对了不要别的什么科学计算环境下运行rails虚拟环境
其实就是anaconda,会触发LoadError
测试失败 之 固件错误 显示nil
解决方法: 在test/fixtures/xxx.yml 中添加所须要的测试固件
'nil' is not an ActiveModel-compatible object. It must implement :to_partial_path.view的变量是nil ,因此没法渲染界面
解决: 检查对应的controller 中是否认义了这个变量
/.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从新配置包