小编T.J*_*uck的帖子

错误通过Bundler安装mysql2 gem

我试图mysql2通过Bundler 安装gem,但它一直死于以下错误:

** executing command
/home/cc_rails/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rubygems/installer.rb:483:in 'rescue in block in build_extensions': 
ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

/home/cc_rails/.rvm/rubies/ruby-1.9.2-p0/bin/ruby extconf.rb --with-mysql-config=/usr/bin/mysql_config
checking for rb_thread_blocking_region()... yes
checking for mysql.h... no
checking for mysql/mysql.h... no

-----
mysql.h is missing.  please check your installation of mysql and try again.
-----

*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration …
Run Code Online (Sandbox Code Playgroud)

ruby mysql rubygems ruby-on-rails bundler

61
推荐指数
4
解决办法
4万
查看次数

Rails 3 - Bundler/Capistrano错误

我有一个基本的Rails 3应用程序在我的开发盒上本地工作,但是想要尽早测试部署以确保一切正常.我正在使用Capistrano进行部署.

当我运行cap deploy(在所有其他必要的设置之后)时,它会在此命令中出现此错误:

[...]
* executing 'bundle:install'
* executing "bundle install --gemfile /var/www/trex/releases/20100917172521/Gemfile --path /var/www/trex/shared/bundle --deployment --quiet --without development test"

servers: ["www.[my domain].com"]
[www.[my domain].com] executing command
** [out :: www.[my domain].com] sh: bundle: command not found
command finished
[...]
Run Code Online (Sandbox Code Playgroud)

所以看起来它无法bundle在服务器上找到命令.

但是,当我登录到服务器时......

$ ruby -v
ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-linux]
$ rails -v
Rails 3.0.0
$ bundle -v
Bundler version 1.0.0
Run Code Online (Sandbox Code Playgroud)

... bundle命令工作正常.

怎么可能出错?

-

(此外,为了完整:)

$ which ruby
~/.rvm/rubies/ruby-1.9.2-p0/bin/ruby
$ which rails …
Run Code Online (Sandbox Code Playgroud)

capistrano ruby-on-rails bundler ruby-on-rails-3

53
推荐指数
5
解决办法
3万
查看次数

通过标头令牌进行rails-api认证

我想使用rails-api gem special来创建仅限API的应用程序.为了提供身份验证机制,我想使用Railscasts#352中描述的内置authenticate_or_request_with_http_token方法,但此方法在此处缺失.

有没有人对rails-api gem 有经验?

PS我可以看到这种方法,但是这个生产准备好了吗?

authentication ruby-on-rails rails-api

15
推荐指数
1
解决办法
1万
查看次数

如何检查rails功能测试中是否显示文本?

我目前正在为我的控制器编写功能测试,我想检查是否有线路

这是一条测试线

出现在我的页面上.

我试过用

assert_select "p" do
  assert_select "this is the test line"
end
Run Code Online (Sandbox Code Playgroud)

但我觉得这条线路有问题.

在rails 3版本中执行此操作的最佳方法是什么?

testing ruby-on-rails functional-testing

4
推荐指数
2
解决办法
2624
查看次数

has_many:通过formtastic多选字段

我正在尝试使用has_many:through方法建立多对多关系,然后使用多选字段来设置关系.我正在学习本教程:

http://asciicasts.com/episodes/185-formtastic-part-2

但是由于某种原因,表单会显示一个奇怪的十六进制数字并且它会更改每个页面刷新,我不确定我做错了什么.下面是我的模型/视图代码.

company.rb

has_many :classifications
has_many :sics, :through => :classifications
Run Code Online (Sandbox Code Playgroud)

sic.rb

has_many :classifications
has_many :companies, :through => :classifications
Run Code Online (Sandbox Code Playgroud)

classification.rb

belongs_to :company
belongs_to :sic
Run Code Online (Sandbox Code Playgroud)

_form.html.erb

<% semantic_form_for @company do |f| %>
  <% f.inputs do %>
    <%= f.input :company %>
    <%= f.input :sics %>
  <% end %>
  <%= f.buttons %>
<% end %>
Run Code Online (Sandbox Code Playgroud)

此外,表格看起来像是显示该字段的正确条目数,但显然没有显示该关系的正确名称.

SIC Multi-Select http://web9.twitpic.com/img/103694166-98ad71116216d3d1b12dd77690b36248.4bf6ca20-full.jpg

ruby-on-rails formtastic

2
推荐指数
1
解决办法
3394
查看次数