I have a model called "Media", database table "Medias". I had to rename that model to "Medium" and the database table to "Mediums". and now when I run my application , I get the following error: ActiveRecord::StatementInvalid in MediumsController#index SQLite3::SQLException: no such table: media: SELECT * FROM "media" Application Trace: C:/IR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract_adapter.rb:219:in `log'' C:/IR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/sqlite_adapter.rb:172:in `execute'' C:/IR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/sqlite_adapter.rb:417:in `catch_schema_changes'' C:/IR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/sqlite_adapter.rb:172:in `execute'' C:/IR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/sqlite_adapter.rb:320:in `select'' C:/IR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `select_all_without_query_cache'' C:/IR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/query_cache.rb:60:in `select_all'' C:/IR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/query_cache.rb:81:in `cache_sql'' C:/IR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/query_cache.rb:60:in `select_all'' C:/IR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/base.rb:661:in `find_by_sql'' C:/IR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/base.rb:1548:in `find_every'' C:/IR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/base.rb:615:in `find'' C:/IR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/base.rb:635:in `all'' C:/IR/rails_apps/work/ProjectBroadcast/app/controllers/mediums_controller.rb:6:in `index'' Note: I am using sqlite3 I don''t have any table called ''media'' in my application, I wonder why its doing a select from that table I tried rake db:migrate:reset and it was successful. Any help is hugely appreciated Thanks! -- Posted via http://www.ruby-forum.com/.
I think you missed to reset your database using rake db:reset after having changed the model name & the corresponding migrations. Thanks & Regards, Dhruva Sagar. On Tue, Nov 10, 2009 at 9:01 AM, Lady Hawk <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > I have a model called "Media", database table "Medias". I had to rename > that model to "Medium" and the database table to "Mediums". > and now when I run my application , I get the following error: > > ActiveRecord::StatementInvalid in MediumsController#index > SQLite3::SQLException: no such table: media: SELECT * FROM "media" > > Application Trace: > > C:/IR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract_adapter.rb:219:in > `log'' > > C:/IR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/sqlite_adapter.rb:172:in > `execute'' > > C:/IR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/sqlite_adapter.rb:417:in > `catch_schema_changes'' > > C:/IR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/sqlite_adapter.rb:172:in > `execute'' > > C:/IR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/sqlite_adapter.rb:320:in > `select'' > > C:/IR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in > `select_all_without_query_cache'' > > C:/IR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/query_cache.rb:60:in > `select_all'' > > C:/IR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/query_cache.rb:81:in > `cache_sql'' > > C:/IR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/query_cache.rb:60:in > `select_all'' > > C:/IR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/base.rb:661:in > `find_by_sql'' > > C:/IR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/base.rb:1548:in > `find_every'' > > C:/IR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/base.rb:615:in > `find'' > > C:/IR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/base.rb:635:in > `all'' > > C:/IR/rails_apps/work/ProjectBroadcast/app/controllers/mediums_controller.rb:6:in > `index'' > > Note: I am using sqlite3 > > I don''t have any table called ''media'' in my application, I wonder why > its doing a select from that table > > I tried rake db:migrate:reset and it was successful. > > Any help is hugely appreciated > > Thanks! > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Marnen Laibow-Koser
2009-Nov-10 04:48 UTC
Re: Renaming a model and table leads to SQL Exception
Dhruva Sagar wrote:> I think you missed to reset your database using rake db:reset after > having > changed the model name & the corresponding migrations. > > Thanks & Regards, > Dhruva Sagar. >Try restarting the app first.> > > > On Tue, Nov 10, 2009 at 9:01 AM, Lady Hawk > <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.orgBest, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/.
Frederick Cheung
2009-Nov-10 06:51 UTC
Re: Renaming a model and table leads to SQL Exception
On Nov 10, 3:31 am, Lady Hawk <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I have a model called "Media", database table "Medias". I had to rename > that model to "Medium" and the database table to "Mediums". > and now when I run my application , I get the following error: > > ActiveRecord::StatementInvalid in MediumsController#index > SQLite3::SQLException: no such table: media: SELECT * FROM "media" >Rails things that the plural of medium is media, so is looking for a table called media for the model medium. Either tell the inflector what you want the plural of medium to be or use set_table_name Fred> Application Trace: > C:/IR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/conn ection_adapters/abstract_adapter.rb:219:in > `log'' > C:/IR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/conn ection_adapters/sqlite_adapter.rb:172:in > `execute'' > C:/IR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/conn ection_adapters/sqlite_adapter.rb:417:in > `catch_schema_changes'' > C:/IR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/conn ection_adapters/sqlite_adapter.rb:172:in > `execute'' > C:/IR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/conn ection_adapters/sqlite_adapter.rb:320:in > `select'' > C:/IR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/conn ection_adapters/abstract/database_statements.rb:7:in > `select_all_without_query_cache'' > C:/IR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/conn ection_adapters/abstract/query_cache.rb:60:in > `select_all'' > C:/IR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/conn ection_adapters/abstract/query_cache.rb:81:in > `cache_sql'' > C:/IR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/conn ection_adapters/abstract/query_cache.rb:60:in > `select_all'' > C:/IR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/base .rb:661:in > `find_by_sql'' > C:/IR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/base .rb:1548:in > `find_every'' > C:/IR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/base .rb:615:in > `find'' > C:/IR/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/base .rb:635:in > `all'' > C:/IR/rails_apps/work/ProjectBroadcast/app/controllers/mediums_controller.r b:6:in > `index'' > > Note: I am using sqlite3 > > I don''t have any table called ''media'' in my application, I wonder why > its doing a select from that table > > I tried rake db:migrate:reset and it was successful. > > Any help is hugely appreciated > > Thanks! > -- > Posted viahttp://www.ruby-forum.com/.
Dhruva Sagar wrote:> I think you missed to reset your database using rake db:reset after > having > changed the model name & the corresponding migrations. > > Thanks & Regards, > Dhruva Sagar. > > > > > On Tue, Nov 10, 2009 at 9:01 AM, Lady Hawk > <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.orgAs you said I tried rake db:reset ,but it still gives the same error. I even restarted the server. IS rake db:reset different from rake db:migrate:reset? I tried both . Thanks! -- Posted via http://www.ruby-forum.com/.
saravanan bava
2009-Nov-10 11:45 UTC
Re: Renaming a model and table leads to SQL Exception
Hi Have u changed the model name in ur controller query. which is in index method. Please check first. On Tue, Nov 10, 2009 at 4:59 PM, Lady Hawk <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Dhruva Sagar wrote: > > I think you missed to reset your database using rake db:reset after > > having > > changed the model name & the corresponding migrations. > > > > Thanks & Regards, > > Dhruva Sagar. > > > > > > > > > > On Tue, Nov 10, 2009 at 9:01 AM, Lady Hawk > > <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org > > As you said I tried rake db:reset ,but it still gives the same error. I > even restarted the server. > IS rake db:reset different from rake db:migrate:reset? I tried both . > Thanks! > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> On Nov 10, 3:31�am, Lady Hawk <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: >> I have a model called "Media", database table "Medias". I had to rename >> that model to "Medium" and the database table to "Mediums". >> and now when I run my application , I get the following error: >> >> ActiveRecord::StatementInvalid in MediumsController#index >> SQLite3::SQLException: no such table: media: SELECT * FROM "media" >> > Rails things that the plural of medium is media, so is looking for a > table called media for the model medium. Either tell the inflector > what you want the plural of medium to be or use set_table_name > > FredYou are so true...That worked . Thanks a lot!! :-) -- Posted via http://www.ruby-forum.com/.
saravanan bava
2009-Nov-10 11:46 UTC
Re: Renaming a model and table leads to SQL Exception
Because the error is in ur mediums controller "ActiveRecord::StatementInvalid in MediumsController#index" On Tue, Nov 10, 2009 at 5:15 PM, saravanan bava <ssbava-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi > Have u changed the model name in ur controller query. which is in index > method. Please check first. > > > On Tue, Nov 10, 2009 at 4:59 PM, Lady Hawk < > rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > >> >> Dhruva Sagar wrote: >> > I think you missed to reset your database using rake db:reset after >> > having >> > changed the model name & the corresponding migrations. >> > >> > Thanks & Regards, >> > Dhruva Sagar. >> > >> > >> > >> > >> > On Tue, Nov 10, 2009 at 9:01 AM, Lady Hawk >> > <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org >> >> As you said I tried rake db:reset ,but it still gives the same error. I >> even restarted the server. >> IS rake db:reset different from rake db:migrate:reset? I tried both . >> Thanks! >> -- >> Posted via http://www.ruby-forum.com/. >> >> >> >> >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---