Tag: mysql

无法在Windows上为rails 3安装mysql2

没有错误消息无法安装mysql2。 我已经尝试过各种我能想到的方法,包括使用devkit。 gem install mysql2 — –with-mysql-include=c:/xampp/mysql/inclu de –with-mysql-lib=c:/xampp/mysql/lib –with-mysql-config=c:/xampp/mysql/bin/my sql_config Temporarily enhancing PATH to include DevKit… Building native extensions. This could take a while… ERROR: Error installing mysql2: ERROR: Failed to build gem native extension. C:/RailsInstaller/Ruby192/bin/ruby.exe extconf.rb –with-mysql-include=c:/xampp/ mysql/include –with-mysql-lib=c:/xampp/mysql/lib –with-mysql-config=c:/xampp/m ysql/bin/mysql_config checking for rb_thread_blocking_region()… yes checking for main() in -llibmysql… no *** extconf.rb […]

gem install mysql失败

我按照http://geryit.com/blog/2011/01/installing-mysql-with-rails-on-mac-os-x-snow-leopard/上的说明进行操作,包括通过macport安装ruby。 每当我执行gem install mysql时 ,我都会收到以下错误 bash-3.2# gem install mysql Building native extensions. This could take a while… ERROR: Error installing mysql: ERROR: Failed to build gem native extension. /opt/local/bin/ruby extconf.rb checking for mysql_ssl_set()… no checking for rb_str_set_len()… no checking for rb_thread_start_timer()… no checking for mysql.h… no checking for mysql/mysql.h… no *** extconf.rb failed *** Could […]

如何在OS X 10.5.4下安装mysql ruby​​ gem

这是交易。 $ gem –version 1.1.0 $ sudo gem install mysql – –with-mysql-config = / usr / local / mysql / bin / mysql_config 批量更新Gem源索引: http : //gems.rubyforge.org/错误:无法在本地或存储库中找到mysql $ sudo gem update 更新已安装的gems批量更新Gem源索引: http : //gems.rubyforge.org/ 更新RedCloth错误:执行gem时…(Gem :: GemNotFoundException)无法在本地或存储库中找到RedCloth 我试过这个 , 这个 , 这个 ,以及其他很多。 他们都没有为我工作。 还有其他人有这个问题吗? 如果是这样你做了什么来解决它上面没有提到的?

错误:安装mysql2时出错:错误:无法构建gem本机扩展

我在尝试为Rails安装gem install mysql2 -v’0.3.17’时遇到了一些问题。 当我尝试通过运行gem install mysql2 -v’0.3.17’或gem install mysql2 -v’0.3.17’来安装它时,它给出了以下错误: ERROR: Error installing mysql2: ERROR: Failed to build gem native extension. Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the file for more details. You may need configuration options. Provided configuration options: –with-opt-dir –with-opt-include –without-opt-include=${opt-dir}/include –with-opt-lib […]

Rails:在同一个应用程序中同时使用mysql和postgres?

为什么你会问? 因为我已经在mysql上构建了应用程序,并且只需要为我的应用程序的GIS组件开始使用postgres。 最终我将完全迁移到postgres,但同时想知道这是否可行

无法从Sequel gem连接mysql

当我尝试从Sequel连接MySQL时。 我收到这些错误: require ‘rubygems’ require ‘sequel’ DB = Sequel.connect(:adapter => ‘mysql’, :user => ‘root’, :host => ‘localhost’, :database => ‘scanty’,:password=>’xx’) DB.tables Sequel::DatabaseConnectionError: NameError uninitialized constant Mysql::CLIENT_MULTI_RESULTS from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/adapters/mysql.rb:98:in `connect’ from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/database.rb:92:in `initialize’ from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/connection_pool.rb:166:in `call’ from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/connection_pool.rb:166:in `make_new’ from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/connection_pool.rb:153:in `available’ from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/connection_pool.rb:144:in `acquire’ from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/connection_pool.rb:143:in `synchronize’ from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/connection_pool.rb:143:in `acquire’ from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/connection_pool.rb:105:in `hold’ from /opt/local/lib/ruby/gems/1.8/gems/sequel-3.2.0/lib/sequel/database.rb:471:in […]

如何使用rails运行简单的MYSQL查询

我想用rails运行一个简单的MYSQL查询 Select movie-title, movie-director from moving order by rating desc limit 5; 我不想要所有开销创建模型。 我只想运行查询。 做这个的最好方式是什么? 我甚至无法连接 这是我的控制器代码 ActiveRecord::Base.establish_connection ({ :adapter => “mysql2”, :host => “some-rds.amazon.com”, :username => “root”, :password => “root”, :database => “blah”}) 这将生成此错误ActiveRecord :: ConnectionNotEstablished 谢谢

‘DELIMITER $$’附近的错误

当我从mysql控制台或MySQL Workbench更改Delimeter时我没有收到任何错误,但当我在轨道上的ruby中嵌入相同的代码时出现错误 mysql> DELIMITER $$ mysql> 没有错误。 但 ActiveRecord::Base.connection.execute(%Q{ DELIMITER $$ }) 得到: ActiveRecord::StatementInvalid: Mysql2::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘DELIMITER $$’ at line 1:

如何在没有模型的情况下从Rails应用程序查询MySQL数据库?

如何从Rails应用程序执行SQL查询到MySQL数据库? 我的应用程序使用Postgres作为主数据库,但我需要从辅助MySQL数据库中读取一些信息。 我无法创建模型,因为MySQL数据库有超过100个表,以不兼容的方式为每个表命名。 可以在没有ActiveRecord或其他方式的情况下完成吗?

如何使用给定值“推进”记录?

我正在使用Ruby on Rails 3.2.9和MySQL。 我有一个带有user_id属性的Article模型(此属性表示外键 – 用于关联作者用户的id ),我想检索为给定作者“订购”的文章。 也就是说,鉴于我有以下记录: … 当我查找为id 1 ( user_id = 1 )的作者订购的文章时,应该按照以下顺序对退回的文章进行排序: … 换句话说,我希望检索所有文章,但是使用这个“优先级”进行排序 : 由给定作者创建的文章首先返回,然后是所有其他文章 (也就是说,我想“推进”由鉴于作者)。 我该怎么做? 注意 :我正在寻找Ruby on Rails实现,可能通过order方法。