我正在使用Ubuntu并在使用db:migrate for ruby项目时遇到问题.
rails aborted!
LoadError: Error loading the 'sqlite3' Active Record adapter. Missing a gem it depends on? can't activate sqlite3 (~> 1.3.6), already activated sqlite3-1.4.0. Make sure all dependencies are added to Gemfile.
/home/juan/odin_on_rails/RailsaAPP/bin/rails:9:in `<top (required)>'
/home/juan/odin_on_rails/RailsaAPP/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
Caused by:
Gem::LoadError: can't activate sqlite3 (~> 1.3.6), already activated sqlite3-1.4.0. Make sure all dependencies are added to Gemfile.
/home/juan/odin_on_rails/RailsaAPP/bin/rails:9:in `<top (required)>'
/home/juan/odin_on_rails/RailsaAPP/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
Tasks: TOP => db:migrate => db:load_config …
Run Code Online (Sandbox Code Playgroud) 我已经发现,当我想设置值的文本字段,文本区域或密码字段,我可以用ID,名称或标记为something
在fill_in something, :with => some_value
.然而,当我尝试将值设置为<input type="hidden">
字段时,这种方法失败了(我想这样做,因为那些通常是填充的客户端脚本,我单独测试).我怎么能用Capybara设置这样一个隐藏的场地?可能吗?
HTML:
<input id='offer_latitude' name='offer[latitude]' type='hidden'>
<input id='offer_longitude' name='offer[longitude]' type='hidden'>
Run Code Online (Sandbox Code Playgroud)
规格:
describe "posting new offer" do
it "should add new offer" do
visit '/offer/new'
fill_in 'offer[latitude]', :with => '11.11'
fill_in 'offer[longitude]', :with => '12.12'
click_on 'add'
end
end
Run Code Online (Sandbox Code Playgroud)
得到:
1) posting new offer should add new offer
Failure/Error: fill_in 'offer[latitude]', :with => '11.11'
Capybara::ElementNotFound:
cannot fill in, no text field, text area or password field with id, name, or …
Run Code Online (Sandbox Code Playgroud) 病原体对我不起作用.我跟随Adam Lowe在这里发布的提示(还有更多)没有任何成功......
我的vimrc:
filetype off
call pathogen#runtime_append_all_bundles()
filetype plugin indent on
set nocompatible
syntax on
set tabstop=2
set smarttab
set shiftwidth=2
set autoindent
set expandtab
set number
colorscheme darkblue
Run Code Online (Sandbox Code Playgroud)
.vim的内容 - ls .vim/*
:
.vim/autoload:
pathogen.vim
.vim/bundle:
nerdcommenter/ vim-haml/ vim-surround/
vim-endwise/ vim-rails/ vim-vividchalk/
Run Code Online (Sandbox Code Playgroud)
通过将它们从GitHub克隆到bundle目录中来安装bundle中的所有插件.
我尝试过使用病原体1.1和1.2,甚至是最新的GitHub,没有任何结果.Vividchalk,Vim-rails和nerdcommenter无法正常工作.我对其他插头的经验很少,所以我不确定它们,但我想它们也没有用.
我正在使用ArchLinux,vim 7.2.385-1(不是最新的,因为最新版本要求我安装ruby1.9,但它仍然是7.2).它已经通过pacman-ArchLinux软件包管理器安装.除了使用病原体之外,没有安装vim插件(我甚至重新安装了带有清洁功能的vim包/usr/share/vim
).
我究竟做错了什么?
编辑:
/etc/vimrc
http://hpaste.org/fastcgi/hpaste.fcgi/view?id=29685#a29685/usr/share/vim/vimfiles/archlinux.vim
http://hpaste.org/fastcgi/hpaste.fcgi/view?id=29686#a29686我有这样的承诺
commit 8a183536da1641afa6bd5a27ae391b387b7cd052
Author: hidden
AuthorDate: Fri Sep 7 10:13:59 2012
Commit: hidden
CommitDate: Fri Dec 7 17:29:24 2012
Run Code Online (Sandbox Code Playgroud)
我想过滤日志并通过AuthorDate显示提交.
我试着--since
和--until
选项,但它实际上过滤CommitDate.
这意味着我只能通过提交
git log --since='2012-12-01' --until='2012-12-10'
Run Code Online (Sandbox Code Playgroud)
如果我想通过start_date'2012-09-01'和end_date'2012-09-10'获取提交过滤器
有小费吗?
由于它实现所有CRUD操作的控制器:new
,create
,delete
,edit
,index
show
,update
,也有几个自定义操作,没有任何常规的(官方与否)为了这些行动要坚持?
我正在使用RSpec + Capybara + Selenium(Firefox)进行测试.无论我运行的验收测试的哪个子集,第一个失败(下一个测试都能正常工作),其中"reason"如下:
Failure/Error: visit '/'
Timeout::Error:
Timeout::Error
Run Code Online (Sandbox Code Playgroud)
我的应用程序严重依赖于GoogleMaps和BackboneJS.当我运行测试时,页面无法加载并且"从maps.googleapis.com传输数据"消息保留在Firefox窗口的左下角,但是页面看起来像是正确加载的(地图和其他内容存在).我已将超时设置为60秒,以排除任何慢速网络问题.并且所有后续测试都可以非常快速地工作(例如,已经提取了适当的Google脚本并且已经缓存).此外,当我在开发环境中启动服务器并访问它(localhost:3000
)时一切正常.
Firefox 17.0.1.我的一些宝石:
capybara (2.0.1)
database_cleaner (0.9.1)
mongoid (3.0.13)
rspec (2.12.0)
rspec-core (2.12.1)
rspec-expectations (2.12.0)
rspec-mocks (2.12.0)
rspec-rails (2.12.0)
selenium-webdriver (2.26.0)
Run Code Online (Sandbox Code Playgroud)
你知道为什么会发生这种情况以及如何预防吗?
编辑:
spec/spec_helper.rb
:
# This file is copied to spec/ when you run 'rails generate rspec:install' ENV["RAILS_ENV"] ||= 'test' require File.expand_path("../../config/environment", __FILE__) require 'rspec/rails' require 'rspec/autorun' # Requires supporting ruby files with custom matchers and macros, etc, # in spec/support/ and its subdirectories. Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require …
MySQL中的存储过程失败了Mysql::Error: Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8_unicode_ci,IMPLICIT) for operation '='
.
当in SELECT
子句尝试将VARCHAR
列与VARCHAR
传递给此过程的参数进行比较时,该过程失败.
我表中的所有列都有utf8_unicode_ci
排序规则.数据库整理是一样的.我甚至在`/config/database.yml中指定了排序规则.
但是,当我运行时,我/script/console
设置了以下变量:
>> ActiveRecord::Base.connection.select_rows "show variables like '%colla%'"
=> [["collation_connection", "utf8_general_ci"], ["collation_database", "utf8_unicode_ci"], ["collation_server", "utf8_general_ci"]]
Run Code Online (Sandbox Code Playgroud)
可能最有趣的事实是,我在同一个MySQL服务器上有另一个数据库具有相同的排序规则(甚至从Rails控制台查询排序规则变量给出相同的结果),它运行这个存储过程没有任何问题.
谢谢你的帮助.
制作一个自己的自定义异常时
class ThingExploded < StandardError; end
class ThingIsMissing < StandardError; end
Run Code Online (Sandbox Code Playgroud)
保存这些的好地方在哪里?我正在考虑lib/exceptions.rb ...并且还在考虑是否更适合以某种方式使它们更接近使用它们的代码.
我想在rails控制台中显示一些活动记录,我启用了Hirb.该表足够窄以便显示(因此Hirb使用标准的水平表)但是列非常窄,内容完全不可读.你知道我能做些什么吗?
只显示几列很棒(我在纯数组中有记录,而不是AR集合,所以我不能只传递:select
给finder方法).迫使Hirb在垂直表中显示记录也是完美的.
提前致谢.
我将在一个应用程序中利用Mongoid的单一集合继承.但是,有一个地方我想禁用此功能.我正在考虑数据库迁移(使用mongoid_rails_migrations gem),我重新定义模型以使我的迁移更易于维护.在这种情况下,我希望将该_type
字段视为普通属性.
如何在Mongoid中实现它?