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;
}







0















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










share|improve this question































    0















    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










    share|improve this question



























      0












      0








      0


      1






      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










      share|improve this question
















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jul 6 '11 at 0:33









      basicxman

      1,9991320




      1,9991320










      asked Jul 5 '11 at 23:50









      hoitomthoitomt

      490415




      490415
























          2 Answers
          2






          active

          oldest

          votes


















          0














          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.






          share|improve this answer
























          • 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



















          0














          There were two things that I did to fix this:




          1. 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

          2. 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






          share|improve this answer
























            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
            });


            }
            });














            draft saved

            draft discarded


















            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









            0














            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.






            share|improve this answer
























            • 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
















            0














            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.






            share|improve this answer
























            • 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














            0












            0








            0







            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.






            share|improve this answer













            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.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            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



















            • 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













            0














            There were two things that I did to fix this:




            1. 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

            2. 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






            share|improve this answer




























              0














              There were two things that I did to fix this:




              1. 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

              2. 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






              share|improve this answer


























                0












                0








                0







                There were two things that I did to fix this:




                1. 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

                2. 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






                share|improve this answer













                There were two things that I did to fix this:




                1. 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

                2. 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







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jul 11 '11 at 22:08









                hoitomthoitomt

                490415




                490415






























                    draft saved

                    draft discarded




















































                    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.




                    draft saved


                    draft discarded














                    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





















































                    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







                    Popular posts from this blog

                    Xamarin.iOS Cant Deploy on Iphone

                    Glorious Revolution

                    Dulmage-Mendelsohn matrix decomposition in Python