我正在尝试编写一个循环,它将返回来自ruby的Faker gem中的25个唯一的名字,条件是每个名字都是>= 5个字符。 我已经设法创建了返回25个唯一名称的循环,但无法正确地产生name.length条件。我尝试了以下几种方法: 尝试1: names = [Faker::Name.unique.first_name]
names.each do |name|
puts name if first_name.length >= 5
25.times do
puts "#{Faker::Name.unique.first_name}"
end
更新:当我从根目录运行rake test时,我得到:
C:\workspace\faker>rake test
DL is deprecated, please use Fiddle
C:/RailsInstaller/Ruby2.1.0/bin/ruby.exe -w -I"lib;test;." -I"C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib" "C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems
我刚刚克隆了一个新的存储库,并完成了捆绑包安装和捆绑包更新。我不知道为什么当我使用包exec rails c时会出现以下错误。我使用的是rails版本5.0.1
bundler: failed to load command: rails (/Users/user123/.rbenv/versions/2.3.1/bin/rails)
Gem::LoadError: railties is not part of the bundle. Add it to Gemfile.
/Users/user123/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/g
我正在尝试升级到Rails 4.0.0,并且我更改了sass-rails和coffee-rails的gem版本。在升级到Rails4之前,我需要解决rails和coffee-rails之间的gem冲突。
当我运行bundle update时,这是我得到的输出:
$ bundle update
Updating git://github.com/pilu/web-app-theme.git
Fetching source index from https://rubygems.org/
Resolving dependencies..............
Bundler could not
当我在env.rb中要求'active_record‘时,我得到了错误
constant Logger::Format not defined (NameError)
/usr/local/rvm/gems/ruby-1.9.3-p125@test/gems/activerecord-1.6.0/lib/active_record/support/clean_logger.rb:5:in remove_const' /usr/local/rvm/gems/ruby-1.9.3-p125@test/gems/activerecord-1.6.0/lib/active_record
当我试图从rails 5.0更新到5.1时,我有了一个实用的应用程序。(我一直在从4.2更新到5.0)
它不再工作了,运行的命令如下:
rails server
产生一个错误。我不知道怎么解决这个问题,我也找不到任何信息,这很奇怪,因为它指向了伪造者的代码,而不是我的代码。
这是控制台输出
/home/gaston/.rvm/gems/ruby-2.3.1/gems/bundler-1.13.7/lib/bundler/runtime.rb:94:in rescue in block (2 levels) in require': There was an error while
我正在尝试在Heroku上迁移我的postgresql数据库。当我运行"heroku run rake db:migrate fails“时,我收到这个错误:
Running `rake db:migrate` attached to terminal... up, run.4898
/usr/bin/env: ruby1.9.1: No such file or directory
当我运行"heroku run ruby -v“时:
Running `ruby -v
目前,我的计算机上安装了1.0.1和1.2.1两个版本的rack,然而,当我尝试将我的git推送到Heroku时,它报告
You have already activated rack 1.0.1, but your Gemfile requires rack 1.2.1. Consider using bundle exec. (Gem::LoadError)
如何停用1.0.1机架,改为激活1.2.1机架?(我不能卸载1.0.1,因为它在system文件夹下,并且我没有root密码)
gem list -d rack
*** LOCAL GEMS ***
当我做“rspec_junit_formatter”时有问题
包exec格式RspecJunitFormatter
我有这样的错误,怎么解决呢?
home/stasyan/.rvm/gems/ruby-2.1.1/gems/rspec-core-3.0.4/lib/rspec/core/formatters/deprecation_formatter.rb:186:in `puts': Treating `metadata[:execution_result]` as a hash is deprecated. Use the attributes methods to access
我是这样安装的:
sudo apt-get install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev ruby1.9.1
mkdir rubysource
cd rubysource
wget http://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p247.tar.gz
tar -xvzf ruby-2.0.0-p247.tar.gz
cd ruby-2.0.0-p247/
./configure --prefix=/usr/local
make
make
bundle install
Fetching source index for http://rubygems.org/
Could not find gem 'annotate-models (= 1.0.4) ruby' in any of the gem sources listed in your Gemfile.
但很明显它在我的文件里,不是吗?
源'‘
gem 'rails', '3.0.0'
gem 'sqlite3-ruby', '1.2.5', :require => 's
我一直在跟踪Rails测试的介绍,遇到了一个我似乎找不到解决方案的问题。我非常熟悉Rails,但这是我第一次尝试测试。
无论如何,我有一个非常基本的模型测试,甚至没有完全实现,而且当我尝试运行rspec spec/models/admin_spec.rb时。我在Admin has a valid factory行中得到以下错误(下面是完整的代码)
Admin has a valid factory
Failure/Error: Factory.create(:admin).should be_valid
NameError:
uninitialized constant Factor
Before(:all) do
puts "HELLO ALL :D"
end
我的代码有一些问题:
/spec/factories.rb
require 'faker'
FactoryGirl.define do
factory :booking_error do
booking_id { Faker::Number.number(3).to_i }
error_type_cd BookingError.error_types.values.shuffle.first
process_name
我无法加载gem factory_girl_rails来正确运行我的测试。我检查了所有的地方但我解决不了。以下是我运行spec时的错误:
/Users/qcherifi/.rvm/gems/ruby-2.3.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:80:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'factory_girl_rails'. (Bundler::GemRequireEr
我正在尝试运行"bundle install“。我已经安装了Ruby devkit,并将其添加到我的路径中。它抱怨make不是一个公认的命令。这不是devkit应该添加的内容吗?在搜索这个问题的答案时,每个答案似乎都是"install devkit“。我使用的是Windows7,配置我的环境以允许其构建gem的最简单方法是什么?
我收到以下输出:
$ bundle install
Fetching source index for http://rubygems.org/
Using rake (0.8.7)
Using activesupport (2.3.11)
Using
在进行捆绑安装时出现此错误;谷歌搜索似乎是一个常见的问题,但我似乎找不到修复程序(在Gemfile.lock上似乎是建议的,但我将该文件移到了另一个目录)
# bundle install
Your bundle only supports platforms [] but your local platforms are ["ruby", "x86_64-linux"], and there's no compatible match between those two lists.
这是我的Gemfile,目录中没有Gemfile.lock。
[r
.rvm/gems/ruby-1.9.3-head/gems/bundler-1.0.21/lib/bundler/runtime.rb:31:in `block in setup': You have already activated rack 1.4.0,
but your Gemfile requires rack 1.2.5. Using bundle exec may solve this. (Gem::LoadError)
是当我尝试在我的任何应用程序上运行thin start,bundle exec thin,rails s时得到的错误。我已经尝试运行系统级和
我目前在michael教程的第10章中,当我尝试包exec rake db时会出现一个问题:populate。
所附的是错误消息:
rake aborted!
ActiveRecord::RecordInvalid: Validation failed: Email has already been taken
我安装了pg宝石,但是.
Building native extensions. This could take a while...
Successfully installed pg-0.11.0
ERROR: Could not find a valid gem '—' (>= 0) in any repository
ERROR: Could not find a valid gem '–with-pg-config=/usr/local/pg/bin/pg_config' (>= 0) in any repos