mysql2

`heroku open` fails - table doesn't exist error in logs

不想你离开。 提交于 2019-12-13 20:52:10
问题 Edit: While trying to get this working, I commented out the offending factory_girl entirely - and it's still giving the same error - cannot load such file -- factory_girl_rails /app/lib/tasks/sample_data.rake:1:in require' is there something i need to do to make heroku work with/see my updated files? OP: heroku open returns We're sorry, but something went wrong. in the browser and the following from heroku logs : 2013-08-23T21:18:48.870042+00:00 app[web.1]: Started GET "/" for 86.59.188.18 at

How do I create a prepared insert statement in Sequel?

谁都会走 提交于 2019-12-13 17:27:14
问题 I am attempting to create a prepared insert statement in Sequel and I am as far as db[:registration].prepare(:insert) => <Sequel::Mysql2::Dataset/PreparedStatement "INSERT INTO `registration` () VALUES ()"> How do I create a statement that is something like the following: INSERT INTO `registration` (`name`, `email`) VALUES (?, ?) The documentation is a little bit obtuse and I can't find any examples online. 回答1: Figured this out looking at their rspecs: statement = db[:registration].prepare(

Rails 4, RSpec, MySQL2 default value error on first factory only

别说谁变了你拦得住时间么 提交于 2019-12-13 12:22:53
问题 I'm upgrading from Rails 3.2.14 to Rails 4. When running RSpec on my test suite in my Rails 3 branch, all tests pass. On the Rails 4 branch, however, I'm getting an error on the first instance only of creating a factory. The error reads: ActiveRecord::StatementInvalid: Mysql2::Error: Field 'id' doesn't have a default value: INSERT INTO `of_of_measurements` (`aerobic_steps`, `calories`, `date`, `device_serial`, `distance`, `is_device_input`, `server_time`, `total_steps`, `user_id`) VALUES (15,

Rails cannot generate model using mysql

倾然丶 夕夏残阳落幕 提交于 2019-12-13 05:19:27
问题 Windows XP with installed MYSQL as a development machine, ruby 1.9.2p290 (2011-07-09) [i386-mingw32], Rails 3.1.0 gem install mysql2 -- '--with-mysql-lib="c:\Program Files\MySQL\MySQL S erver 5.5\lib" --with-mysql-include="c:\Program Files\MySQL\MySQL Server 5.5\inc lude"' (successfully installed gem mysql2) rails new talk -d mysql (successfully created a new rails app called talk) PROBLEM NOW STARTS: C:\Sites\RP\talk>rails generate User ERROR MESSAGE: ruby.exe-Unable to Locate Component This

How to create/maintain ID field in Sequel Pro via Ruby and mysql2

眉间皱痕 提交于 2019-12-12 05:29:07
问题 In Sequel Pro, created a table using this statement: CREATE TABLE dogs( id INT PRIMARY KEY AUTO_INCREMENT, name TEXT, color TEXT ); Since the id value is being created by MySQL, I would like to set/create/maintain the id field in ruby so that puts dog.id will not be an empty string. Was wondering if this piece of code would accomplish that: def new_from_hash(hash) Dog.new(hash["name"], hash["color"]).tap {|dog| dog.id = hash["id"]} end NOTE: I am not running rails; just plain ruby, the gem

Replace Mysql database from one Computer to Other in Rails as we do in sqlite3

雨燕双飞 提交于 2019-12-11 09:47:46
问题 I switched to mysql dtabase in Rails.I got a databse.sql file generated in db folder.But when i login to mysql and check data in tables then there is no records present in tables. i used this command for dump mysql –u root –p database_name < database_name.sql there was no error while executing this command but when i checked the tables then there were no records in the tables.So please help me to insert all my records in database using database.sql file.There is one fiel generated database.sq

mysql2 0.4.0 ruby gem require error

时光总嘲笑我的痴心妄想 提交于 2019-12-11 03:48:56
问题 I installed mysql2 gem using command: gem install mysql2 Done installing documentation for mysql2 after 0 seconds 1 gem installed But when I do require 'mysql2' , I get: LoadError: cannot load such file -- mysql2/mysql2 Even though the gem installed successfully, gem list mysql2 *** LOCAL GEMS *** mysql2 (0.4.0) I am using MacOSX with ruby 2.1.5p273 Any suggestions as to where should I be looking ? 回答1: Are you sure you have quoted gem name like this require 'mysql2' ? Please, show your

Rails 3, mysql/mysql2 misinterpreting some retrieved strings as ASCII-8BIT

半城伤御伤魂 提交于 2019-12-10 17:56:37
问题 This problem began as the commonly-seen “incompatible character encodings: ASCII-8BIT and UTF-8” problem, but that is not what I'm asking. Rather, I discovered that this problem was happening because certain fields of my database are being tagged as ASCII-8BIT when they're retrieved, while most are correctly shown as UTF-8. For example, in a table with columns country and nationality , where both columns in row 16 have identical values (copied-and-pasted), I get irb(main):003:0> c = Country

mysql2 gem installed fine but still getting “Please install the myslq2 adapter…” when running “rake db:migrate”

左心房为你撑大大i 提交于 2019-12-10 16:09:17
问题 I've read through numerous posts here regarding mysql2, but although the gem seems to install fine, I still get error when running any rake db tasks or rails commands. In my Gemfile: source 'http://rubygems.org' gem 'rails', '3.0.7' gem 'mysql2' On my remote server I ran the following: $ bundle install ... Using mysql2 (0.2.7) ... Using rails (3.0.7) ... Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed. $ rake db:schema:load (in ...) rake aborted!

Ruby / MySQL fetching single row but still using .each?

不问归期 提交于 2019-12-10 14:29:58
问题 I'm using the MySQL2 Ruby driver - but it seems a bit redundant having to call result.each{ |r| puts r['name'] } for a single row of data that is returned. There must be a simpler way to get the mysql field I want without having to use the each block? 回答1: Your result should be a Mysql2::Result and that's Enumerable so you can use first (and the rest of the Enumerable goodies) on it: puts result.first['name'] 来源: https://stackoverflow.com/questions/14064649/ruby-mysql-fetching-single-row-but