Ruby on Rails Testing with MySQL
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I'm trying to test with Ruby on Rails with a MySQL database. When attempting to run the test each test fails with the same reason:
ActiveRecord::StatementInvalid: Mysql::Error: Table 'db_test.session_cleaners' doesn't exist: DELETE FROM `session_cleaners`
I created a session_cleaners table with a primary key and am now getting this error:
ActiveRecord::StatementInvalid: Mysql::Error: Duplicate entry '0' for key 'PRIMARY': INSERT INTO `session_cleaners` () VALUES ()
I doubt I need the session_cleaners
table but I'm not sure what else to do. Any help would be appreciated.
Thanks
ruby-on-rails
add a comment |
I'm trying to test with Ruby on Rails with a MySQL database. When attempting to run the test each test fails with the same reason:
ActiveRecord::StatementInvalid: Mysql::Error: Table 'db_test.session_cleaners' doesn't exist: DELETE FROM `session_cleaners`
I created a session_cleaners table with a primary key and am now getting this error:
ActiveRecord::StatementInvalid: Mysql::Error: Duplicate entry '0' for key 'PRIMARY': INSERT INTO `session_cleaners` () VALUES ()
I doubt I need the session_cleaners
table but I'm not sure what else to do. Any help would be appreciated.
Thanks
ruby-on-rails
add a comment |
I'm trying to test with Ruby on Rails with a MySQL database. When attempting to run the test each test fails with the same reason:
ActiveRecord::StatementInvalid: Mysql::Error: Table 'db_test.session_cleaners' doesn't exist: DELETE FROM `session_cleaners`
I created a session_cleaners table with a primary key and am now getting this error:
ActiveRecord::StatementInvalid: Mysql::Error: Duplicate entry '0' for key 'PRIMARY': INSERT INTO `session_cleaners` () VALUES ()
I doubt I need the session_cleaners
table but I'm not sure what else to do. Any help would be appreciated.
Thanks
ruby-on-rails
I'm trying to test with Ruby on Rails with a MySQL database. When attempting to run the test each test fails with the same reason:
ActiveRecord::StatementInvalid: Mysql::Error: Table 'db_test.session_cleaners' doesn't exist: DELETE FROM `session_cleaners`
I created a session_cleaners table with a primary key and am now getting this error:
ActiveRecord::StatementInvalid: Mysql::Error: Duplicate entry '0' for key 'PRIMARY': INSERT INTO `session_cleaners` () VALUES ()
I doubt I need the session_cleaners
table but I'm not sure what else to do. Any help would be appreciated.
Thanks
ruby-on-rails
ruby-on-rails
edited Jul 6 '11 at 0:33
basicxman
1,9991320
1,9991320
asked Jul 5 '11 at 23:50
hoitomthoitomt
490415
490415
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
You should run the migrations and prepare the test database:
bundle exec rake db:migrate
bundle exec rake db:test:prepare
This will take care of everything provided you have valid migrations.
You'd better read the guides - there's plenty of information that people don't even realise.
Thanks for the response, but it didn't help. I created a new test database and set it up properly but am still getting the "session_cleaner" error.
– hoitomt
Jul 6 '11 at 1:59
add a comment |
There were two things that I did to fix this:
- Update the MySQL gem so that I was using 2.7. I'm on Ruby 1.8.6/Rails 2.3.10 so this gem was required
- Create a session_cleaner table with one field: id. The id is not a primary key and does allow null.
These two things made it so I could prepare the test environment
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f6590143%2fruby-on-rails-testing-with-mysql%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You should run the migrations and prepare the test database:
bundle exec rake db:migrate
bundle exec rake db:test:prepare
This will take care of everything provided you have valid migrations.
You'd better read the guides - there's plenty of information that people don't even realise.
Thanks for the response, but it didn't help. I created a new test database and set it up properly but am still getting the "session_cleaner" error.
– hoitomt
Jul 6 '11 at 1:59
add a comment |
You should run the migrations and prepare the test database:
bundle exec rake db:migrate
bundle exec rake db:test:prepare
This will take care of everything provided you have valid migrations.
You'd better read the guides - there's plenty of information that people don't even realise.
Thanks for the response, but it didn't help. I created a new test database and set it up properly but am still getting the "session_cleaner" error.
– hoitomt
Jul 6 '11 at 1:59
add a comment |
You should run the migrations and prepare the test database:
bundle exec rake db:migrate
bundle exec rake db:test:prepare
This will take care of everything provided you have valid migrations.
You'd better read the guides - there's plenty of information that people don't even realise.
You should run the migrations and prepare the test database:
bundle exec rake db:migrate
bundle exec rake db:test:prepare
This will take care of everything provided you have valid migrations.
You'd better read the guides - there's plenty of information that people don't even realise.
answered Jul 6 '11 at 0:22
Dmytrii NagirniakDmytrii Nagirniak
16.1k1163113
16.1k1163113
Thanks for the response, but it didn't help. I created a new test database and set it up properly but am still getting the "session_cleaner" error.
– hoitomt
Jul 6 '11 at 1:59
add a comment |
Thanks for the response, but it didn't help. I created a new test database and set it up properly but am still getting the "session_cleaner" error.
– hoitomt
Jul 6 '11 at 1:59
Thanks for the response, but it didn't help. I created a new test database and set it up properly but am still getting the "session_cleaner" error.
– hoitomt
Jul 6 '11 at 1:59
Thanks for the response, but it didn't help. I created a new test database and set it up properly but am still getting the "session_cleaner" error.
– hoitomt
Jul 6 '11 at 1:59
add a comment |
There were two things that I did to fix this:
- Update the MySQL gem so that I was using 2.7. I'm on Ruby 1.8.6/Rails 2.3.10 so this gem was required
- Create a session_cleaner table with one field: id. The id is not a primary key and does allow null.
These two things made it so I could prepare the test environment
add a comment |
There were two things that I did to fix this:
- Update the MySQL gem so that I was using 2.7. I'm on Ruby 1.8.6/Rails 2.3.10 so this gem was required
- Create a session_cleaner table with one field: id. The id is not a primary key and does allow null.
These two things made it so I could prepare the test environment
add a comment |
There were two things that I did to fix this:
- Update the MySQL gem so that I was using 2.7. I'm on Ruby 1.8.6/Rails 2.3.10 so this gem was required
- Create a session_cleaner table with one field: id. The id is not a primary key and does allow null.
These two things made it so I could prepare the test environment
There were two things that I did to fix this:
- Update the MySQL gem so that I was using 2.7. I'm on Ruby 1.8.6/Rails 2.3.10 so this gem was required
- Create a session_cleaner table with one field: id. The id is not a primary key and does allow null.
These two things made it so I could prepare the test environment
answered Jul 11 '11 at 22:08
hoitomthoitomt
490415
490415
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f6590143%2fruby-on-rails-testing-with-mysql%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown