Renaming a model and table leads to SQL Exception

View: New views
8 Messages — Rating Filter:   Alert me  

Renaming a model and table leads to SQL Exception

by Adam Akhtar-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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@...
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Renaming a model and table leads to SQL Exception

by Dhruva Sagar :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...> 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@...
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Renaming a model and table leads to SQL Exception

by Adam Akhtar-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
marnen@...
--
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@...
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Renaming a model and table leads to SQL Exception

by Frederick Cheung-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message




On Nov 10, 3:31 am, Lady Hawk <rails-mailing-l...@...>
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/.
--~--~---------~--~----~------------~-------~--~----~
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@...
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Renaming a model and table leads to SQL Exception

by Adam Akhtar-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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

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@...
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Renaming a model and table leads to SQL Exception

by saravanan bava :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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

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@...
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Renaming a model and table leads to SQL Exception

by Adam Akhtar-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Frederick Cheung wrote:

> On Nov 10, 3:31�am, Lady Hawk <rails-mailing-l...@...>
> 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

You are so true...That worked . Thanks a lot!! :-)
--
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@...
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Renaming a model and table leads to SQL Exception

by saravanan bava :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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

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@...
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---