ActiveRecord::StatementInvalid

Subscribe to ActiveRecord::StatementInvalid 25 posts, 2 voices

 
Avatar bolo 21 posts

Hello,

i deployed my application with succes :) But i have a lil problem when if u test this page http://www.expay.uag-histoire.com/faq_categories You will see this error message ActiveRecord::StatementInvalid in Faq categoriesController#index

ActiveRecord::StatementInvalid

I don’t realy understand ‘cause in local, i don’t have this problem …

lil help ?

Thanks

 
Avatar lanaer 28 posts

I get a more general 503 error when clicking that link, but that error would mean that there’s either something wrong with the SQL active record assembled for the db, or there’s something messed up with your db structure at PA (that makes the SQL invalid for that DB). Since it works on your local machine, I’d start looking at the second possibility.

 
Avatar bolo 21 posts

I get a more general 503 error when clicking that link, You don’t see this message ?

ActiveRecord::StatementInvalid (ActiveRecord::StatementInvalid): /vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb:279:in `table_structure’ /vendor/rails/activerecord/lib/../../activesupport/lib/active_support/core_ext/object/misc.rb:23:in `returning’ /vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb:278:in `table_structure’ /vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb:216:in `columns’ /vendor/rails/activerecord/lib/active_record/base.rb:760:in `columns’ /vendor/rails/activerecord/lib/active_record/base.rb:773:in `column_names’ /vendor/rails/activerecord/lib/active_record/base.rb:786:in `column_methods_hash’ /vendor/rails/activerecord/lib/active_record/base.rb:1262:in `all_attributes_exists?’ /vendor/rails/activerecord/lib/../../activesupport/lib/active_support/inflector.rb:162:in `all?’ /vendor/rails/activerecord/lib/active_record/base.rb:1262:in `each’ /vendor/rails/activerecord/lib/active_record/base.rb:1262:in `all?’ /vendor/rails/activerecord/lib/active_record/base.rb:1262:in `all_attributes_exists?’ /vendor/rails/activerecord/lib/active_record/base.rb:1196:in `method_missing’ /app/controllers/faq_categories_controller.rb:20:in `index’ /vendor/rails/actionpack/lib/action_controller/base.rb:1068:in `send’ /vendor/rails/actionpack/lib/action_controller/base.rb:1068:in `perform_action_without_filters’ /vendor/rails/actionpack/lib/action_controller/filters.rb:635:in `call_filter’ /vendor/rails/actionpack/lib/action_controller/filters.rb:637:in `call_filter’ /vendor/rails/actionpack/lib/action_controller/filters.rb:641:in `call_filter’ /vendor/rails/actionpack/lib/action_controller/filters.rb:438:in `call’ /vendor/rails/actionpack/lib/action_controller/filters.rb:640:in `call_filter’ /vendor/rails/actionpack/lib/action_controller/filters.rb:641:in `call_filter’ /vendor/rails/actionpack/lib/action_controller/filters.rb:438:in `call’ /vendor/rails/actionpack/lib/action_controller/filters.rb:640:in `call_filter’ /vendor/rails/actionpack/lib/action_controller/filters.rb:641:in `call_filter’ /vendor/rails/actionpack/lib/action_controller/filters.rb:449:in `call’ /vendor/rails/actionpack/lib/action_controller/filters.rb:640:in `call_filter’ /vendor/rails/actionpack/lib/action_controller/filters.rb:622:in `perform_action_without_benchmark’ /vendor/rails/actionpack/lib/action_controller/benchmarking.rb:66:in `perform_action_without_rescue’ /usr/lib/ruby/1.8/benchmark.rb:293:in `measure’ /vendor/rails/actionpack/lib/action_controller/benchmarking.rb:66:in `perform_action_without_rescue’ /vendor/rails/actionpack/lib/action_controller/rescue.rb:111:in `perform_action’ /vendor/rails/actionpack/lib/action_controller/base.rb:427:in `send’ /vendor/rails/actionpack/lib/action_controller/base.rb:427:in `process_without_filters’ /vendor/rails/actionpack/lib/action_controller/filters.rb:627:in `process_without_session_management_support’ /vendor/rails/actionpack/lib/action_controller/session_management.rb:114:in `process’ /vendor/rails/actionpack/lib/action_controller/base.rb:330:in `process’ /vendor/rails/railties/lib/dispatcher.rb:41:in `dispatch’ /usr/lib/ruby/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel/rails.rb:84:in `process’ /usr/lib/ruby/1.8/sync.rb:229:in `synchronize’ /usr/lib/ruby/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel/rails.rb:83:in `process’ /usr/lib/ruby/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel.rb:580:in `process_client’ /usr/lib/ruby/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel.rb:579:in `each’ /usr/lib/ruby/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel.rb:579:in `process_client’ /usr/lib/ruby/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel.rb:686:in `run’ /usr/lib/ruby/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel.rb:686:in `initialize’ /usr/lib/ruby/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel.rb:686:in `new’ /usr/lib/ruby/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel.rb:686:in `run’ /usr/lib/ruby/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel.rb:673:in `initialize’ /usr/lib/ruby/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel.rb:673:in `new’ /usr/lib/ruby/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel.rb:673:in `run’ /usr/lib/ruby/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel/configurator.rb:267:in `run’ /usr/lib/ruby/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel/configurator.rb:266:in `each’ /usr/lib/ruby/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel/configurator.rb:266:in `run’ /usr/lib/ruby/gems/1.8/gems/mongrel-0.3.13.4/bin/mongrel_rails:127:in `run’ /usr/lib/ruby/gems/1.8/gems/mongrel-0.3.13.4/lib/mongrel/command.rb:211:in `run’ /usr/lib/ruby/gems/1.8/gems/mongrel-0.3.13.4/bin/mongrel_rails:231

or there’s something messed up with your db structure at PA

db structure == shema.rb ?

ActiveRecord::Schema.define(:version => 8) do

create_table "faq_categories", :force => true do |t|
  t.column "libellefr",  :string
  t.column "estvisible", :integer
end
create_table "faq_comments", :force => true do |t|
  t.column "faq_id",     :integer
  t.column "message",    :text
  t.column "nom",        :string
  t.column "email",      :string
  t.column "approved",   :boolean,  :default => false
  t.column "ip",         :string
  t.column "created_at", :datetime
end
create_table "jetons", :force => true do |t|
  t.column "date_assistance", :datetime
  t.column "noticket",        :string
  t.column "nom",             :string
  t.column "email",           :string
  t.column "message",         :text
  t.column "resolu",          :integer
end
create_table "jetons_comments", :force => true do |t|
  t.column "jeton_id",   :integer
  t.column "nom",        :string
  t.column "message",    :text
  t.column "created_at", :string
  t.column "ip",         :string
end
create_table "questions", :force => true do |t|
  t.column "faq_category_id", :integer
  t.column "questionfr",      :string
  t.column "reponsefr",       :text
  t.column "score",           :integer, :default => 0
  t.column "estvisible",      :integer
end
create_table "roles", :force => true do |t|
  t.column "label", :string
  t.column "power", :integer
end
create_table "users", :force => true do |t|
  t.column "login",                     :string
  t.column "email",                     :string
  t.column "crypted_password",          :string,   :limit => 40
  t.column "salt",                      :string,   :limit => 40
  t.column "created_at",                :datetime
  t.column "updated_at",                :datetime
  t.column "remember_token",            :string
  t.column "remember_token_expires_at", :datetime
  t.column "activation_code",           :string,   :limit => 40
  t.column "activated_at",              :datetime
end
create_table "votes", :force => true do |t|
  t.column "faq_id", :integer
  t.column "ip",     :string
  t.column "score",  :integer
end

end

 
Avatar lanaer 28 posts

You use sqlite both locally and at PA?

 
Avatar lanaer 28 posts

Oh, and I do see that error now when I click, though I didn’t before. Odd.

 
Avatar bolo 21 posts

You use sqlite both locally and at PA?

Yes, why ? i can’t use sqlite at PA

Oh, and I do see that error now when I click, though I didn’t before. Odd.

So , your diagnostic ? :)

 
Avatar lanaer 28 posts

Yes, why ? i can’t use sqlite at PA

You should be able to, I was just trying to figure out if that sort of difference might be causing a problem.

Do you mind pasting the index action of your faq_categories_controller and pointing out which line is 20?

 
Avatar lanaer 28 posts

Oh, and if you have sqlite generating any logs, check those for anything interesting.

 
Avatar bolo 21 posts

Do you mind pasting the index action of your faq_categories_controller

http://pastie.caboo.se/25178

and pointing out which line is 20?

@faq_categories = FaqCategory.find_all_by_estvisible(1)

 
Avatar lanaer 28 posts

Ok. After some digging through the source, the part that’s throwing the exception is


       def table_structure(table_name)
          returning structure = execute("PRAGMA table_info(#{table_name})") do
            raise ActiveRecord::StatementInvalid if structure.empty?
          end
        end

I’m assuming that the table_name used in this case would be faq_categories (unless you specified it to be something different). So, if you open up sqlite and try PRAGMA table_info(faq_categories) (can try this on PA and locally, I think), what happens?

 
Avatar bolo 21 posts

at Local

$ sqlite3 db/expay_corporate_development SQLite version 3.1.3 Enter ”.help” for instructions sqlite> PRAGMA table_info(faq_categories) ; 0|id|INTEGER|99||1 1|libellefr|varchar(255)|0||0 2|estvisible|integer|0||0 sqlite>

at PA

sqlite3 expay/current/db/expay_corporate_production

SQLite version 3.3.3 Enter ”.help” for instructions sqlite> PRAGMA table_info(faq_categories) ; sqlite>

 
Avatar lanaer 28 posts

Hm. Well, the command line shows the same problem as the app. I don’t have access to your sqlite instance, but you’d need to figure out why it’s not able to get any info for that table when done at PA (double-check that it exists, and has permissions to read it, and such, I suppose).

 
Avatar bolo 21 posts

I don’t have access to your sqlite instance, but you’d need to figure out why it’s not able to get any info for that table when done at PA

I check the permission in the terminal at PA

$ ls -l expay/current/db/ total 44 -rw-r—r—1 vu2016 vu2016 30720 Nov 30 13:25 expay_corporate_development -rw-r—r—1 vu2016 vu2016 0 Nov 30 13:26 expay_corporate_production -rw-r—r—1 vu2016 vu2016 7168 Nov 30 13:25 expay_corporate_test drwxr-xr-x 3 vu2016 vu2016 255 Nov 30 13:25 migrate -rw-r—r—1 vu2016 vu2016 2385 Nov 30 13:25 schema.rb

 
Avatar lanaer 28 posts

The permissions look fine there.

What result does

sqlite> .schema

give you?

 
Avatar lanaer 28 posts

Um, actually, nevermind. Considering the error I see at http://www.expay.uag-histoire.com/users , I think you just need to run rake migrate. Or, if you did, work on figuring out why it failed.

(Error is SQLite3::SQLException: no such table: users: SELECT * FROM users )

 
Avatar bolo 21 posts

I remigrate my db production in local

pc-mq-dsi3:~/Documents/Coding-Dev/expay bmichelin$ rake RAILS_ENV=production db :migrate (in /Users/bmichelin/Documents/Coding-Dev/expay) CreateFaqcategories: migrating =========================================== —create_table(:faq_categories) → 0.1335s CreateFaqcategories: migrated (0.1337s) ================================== CreateQuestions: migrating =============================================== —create_table(:questions) → 0.0465s CreateQuestions: migrated (0.0468s) ====================================== CreateFaqComments: migrating ============================================= —create_table(:faq_comments) → 0.0304s CreateFaqComments: migrated (0.0307s) ==================================== CreateUsers: migrating =================================================== —create_table(:users) → 0.0343s CreateUsers: migrated (0.0346s) ========================================== CreateRoles: migrating =================================================== —create_table(:roles) → 0.0359s CreateRoles: migrated (0.0361s) ========================================== CreateJetons: migrating ================================================== —create_table(:jetons) → 0.0860s CreateJetons: migrated (0.0862s) ========================================= CreateJetonsComments: migrating ========================================== —create_table(:jetons_comments) → 0.0584s CreateJetonsComments: migrated (0.0586s) ================================= CreateVotes: migrating =================================================== —create_table(:votes) → 0.0430s CreateVotes: migrated (0.0432s) ==========================================

and also at PA (in /var/www/virtual/uag-histoire.com/expay/releases/20061130212424)

rake db:migrate

i have always same problem

my schema sqlite3 db/expay_corporate_production SQLite version 3.3.3 Enter ”.help” for instructions sqlite> .shema unknown command or invalid arguments: “shema”. Enter ”.help” for help sqlite> .schema sqlite>

 
Avatar lanaer 28 posts

When I asked you to try the PRAGMA command, you did it in expay/current/db/expay_corporate_production (I’m assuming the full path is /var/www/virtual/uag-histoire.com/expay/current/db/expay_corporate_production). But you did the migrate command in /var/www/virtual/uag-histoire.com/expay/releases/20061130212424. If you run rake db:migrate from /var/www/virtual/uag-histoire.com/expay/current/, do you still have the same problem?

Also, did you specify the production environment for migrate on PA’s server? (If you run .schema in db/expay_corporate_development, does it show anything?).

 
Avatar bolo 21 posts

you run rake db:migrate from /var/www/virtual/uag-histoire.com/expay/current/, do you still have the same problem?

http://pastie.caboo.se/25309

Also, did you specify the production environment for migrate on PA’s server?

Yes i added production in mongrel_config http://pastie.caboo.se/25312

(If you run .schema in db/expay_corporate_development, does it show anything?).

http://pastie.caboo.se/25311

 
Avatar lanaer 28 posts

Mongrel’s configuration doesn’t effect rake; it only affects what the app itself runs in. Since your development db seems to have everything it’s supposed to, and your app is running in production, I’m guessing your just need to run

rake RAILS_ENV=production db:migrate

on positron (and then probably stop/start (not restart) your mongrel cluster).

 
Avatar bolo 21 posts

local http://pastie.caboo.se/25599

PA http://pastie.caboo.se/25600

Same thing :( http://www.expay.uag-histoire.com/users/new

I deleted my application at PA and redeployed my application but always same thing

I really don’t understand …

 
Avatar lanaer 28 posts

Um, rake RAILS_ENV=production db:migrate should’ve been run at PA, not locally.

 
Avatar bolo 21 posts

Um, rake RAILS_ENV=production db:migrate should’ve been run at PA, not locally.

Ok http://pastie.caboo.se/25730

I forgot something ?

Other people are this problem since they update for Rails 1.2 (like me) http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/068b8085a578031e/ff7069705396ebef#ff7069705396ebef

 
Avatar lanaer 28 posts

It works now. You needed to stop/start your mongrel cluster after doing the rake migrate (as I mentioned in my post on Dec 1).

 
Avatar bolo 21 posts

It works now. You needed to stop/start your mongrel cluster after doing the rake migrate (as I mentioned in my post on Dec 1).

oups i forgot to restart sorry. Thanks a lot ;)

 
Avatar lanaer 28 posts

No problem.