将rails4应用程序部署到VPS时出错.我得到的错误是
rbenv: version `2.0.0' is not installed
Run Code Online (Sandbox Code Playgroud)
但是使用"ruby -v"我得到了
ruby 2.0.0p0 (2013-02-24 revision 39474) [i686-linux]
Run Code Online (Sandbox Code Playgroud)
在我的gemfile中我有
source 'https://rubygems.org'
ruby '2.0.0'
gem 'rails', '4.0.0'
Run Code Online (Sandbox Code Playgroud)
捆绑安装配方后出现此错误
2013-08-04 23:23:56 executing `bundle:install'
* executing "cd /home/yasinishyn/apps/kaiser/releases/20130804202355 && bundle install --gemfile /home/yasinishyn/apps/kaiser/releases/20130804202355/Gemfile --path /home/yasinishyn/apps/kaiser/shared/bundle --deployment --quiet --without development test"
servers: ["xxx.xxx.xxx.xxx"]
[198.211.125.183] executing command
** [out :: xxx.xxx.xxx.xxx] rbenv: version `2.0.0' is not installed
** [out :: xxx.xxx.xxx.xxx]
command finished in 355ms
*** [deploy:update_code] rolling back
* executing "rm -rf /home/yasinishyn/apps/kaiser/releases/20130804202355; true"
servers: ["xxx.xxx.xxx.xxx"]
[xxx.xxx.xxx.xxx] …Run Code Online (Sandbox Code Playgroud) 我使用此代码段连接到另一个数据库
ActiveRecord::Base.establish_connection....
Run Code Online (Sandbox Code Playgroud)
但我不知道如何在不需要之后删除此连接.
我需要将我的应用程序配置为使用多个分片,甚至多个数据库适配器。我注意到所有 rake 命令rake db:migrate都在工作,并且会对 shards.yml 中定义的分片产生影响,除了rake db:create. 手动创建所有这些将是一个真正的痛苦。我怎样才能让它工作?
我的database.yml(我这里已经定义了,只有我的master shard)
development:
adapter: postgresql
host: localhost
encoding: unicode
database: db_workload_master_development
pool: 5
username:
password:
production:
......
Run Code Online (Sandbox Code Playgroud)
我的碎片.yml
octopus:
environments:
- production
- development
development:
shards:
mysql:
host: localhost
adapter: mysql2
database: db_workload_mysql_shard_development
sqlite:
host: localhost
adapter: sqlite3
database: db_workload_sqlite_shard_development
pg:
host: localhost
adapter: postgresql
database: db_workload_pg_shard_development
pool: 5
username:
password:
production:
....
Run Code Online (Sandbox Code Playgroud)
只有来自 database.yml 的数据库是用 rake-task 创建的rake db:create。
我已添加gem 'country-select'到我的gemfile中,我需要在select中列出所有国家/地区.我尝试<%= f.input :country, as: :select %>但是国家没有出现.文档中没有相关信息.请帮我解决这个问题.
带集合的Rails简单表单输入保存对象的id而不是名称.我有简单的收藏:
= address_f.input :state, collection: State.all, :required => true, label: t('content.realty.state')
Run Code Online (Sandbox Code Playgroud)
州有id和name列.作为视图中的输出,我看到正确的选择具有适当的值,但在保存时,保存id而不是名称.
我通过capistrano将应用程序部署到VPS时出错.cap deploy:setup和cap deploy:check执行没有错误!
当我尝试限制部署时:冷或简单的部署,我得到了这个
[deploy:update_code] rolling back
* executing [#<Capistrano::Command::Tree::ElseBranch:0x0000010141e798 @condition="else", @command="rm -rf /home/yasinishyn/apps/mkv/releases/20130505214957; true", @callback=#<Proc:0x0000010140f6a8@/usr/local/rvm/gems/ruby-2.0.0-p0/gems/capistrano-2.15.3/lib/capistrano/configuration/actions/invocation.rb:13>, @options={}, @skip=false>]
servers: ["xxx.xxx.xxx.xxx"]
[xxx.xxx.xxx.xxx] executing command
command finished in 225ms
failed: "sh -c 'cat /home/yasinishyn/apps/mkv/current/REVISION'" on xxx.xxx.xxx.xxx
Run Code Online (Sandbox Code Playgroud)
如何调试?哪里出错?这意味着什么"失败:"sh -c'cat/home/yasinishyn/apps/mkv/current/REVISION'"198.211.125.183"?
deploy.rb:
require "bundler/capistrano"
server "xxx.xxx.xxx.xxx", :web, :app, :db, primary: true
set :application, "app"
set :user, "user"
set :deploy_to, "/home/#{user}/apps/#{application}"
set :deploy_via, :remote_cache
set :use_sudo, false
set :shared_children, shared_children + %w{public/uploads}
set :scm, "git"
set :repository, "git@github.com:git_user/#{application}.git"
set :branch, "master"
default_run_options[:pty] = true
ssh_options[:forward_agent] = …Run Code Online (Sandbox Code Playgroud) 例如,作为输入,我可能会收到"qwer.qwer"或"qwer qwer".在这两种情况下,我需要拆分此字符串,以便得到结果:
["qwer", "qwer"]
Run Code Online (Sandbox Code Playgroud)
我可以使用正则表达式作为分裂器,这个正则表达式看起来像什么?
建议我有用户模型(设计),这个用户必须能够使用他的paypal帐户支付一些服务.所以我想实现paypal_account:
class PaypalAccount < ActiveRecord::base
attr_accessible #paypal credentials
...
belongs_to :user
end
Run Code Online (Sandbox Code Playgroud)
因此,当用户结帐某些服务时,他被重定向到paypal只是为了确认这一点.如果这是可行的:什么属性(db中的字段)paypal_accounts必须有?,如何构建此请求?
验证rails 3.2中创建的has_many对象的数量?
我需要对关联对象的"最大/最小"计数进行自定义验证.我有房地产,有
has_many :realty_images, :dependent => :destroy
accepts_nested_attributes_for :realty_images
Run Code Online (Sandbox Code Playgroud)
和realty_image:
class RealtyImage < ActiveRecord::Base
attr_accessible :avatar, :image, :realty_id
belongs_to :realty
#here a suppose I need to put some kind of custom validation
mount_uploader :image, ImageUploader
end
Run Code Online (Sandbox Code Playgroud) ruby ×5
capistrano ×2
simple-form ×2
activerecord ×1
deployment ×1
octopus ×1
paypal ×1
regex ×1
sharding ×1