Can't Rake Database "Undefined method "each" For SQLite" - ruby-on-rails

Hello I am just getting started putting up a test database. I am using the preloaded rails environment from digital-ocean if that helps anything.
So I have just cloned my application from github and went rake db:create. When I did that it says there is an undefined method each for SQLite. I am not using sqlite though? I have specified PostgreSQL as the adapter.
I am a noob so sorry If this is a dumb question. Thank you in advance.

Use:
rake db:create
Not
rake:db create

I removed SQLite using gem uninstall sqlite3 then restarted the server. Everything started to work after that.

Related

No permission to drop SQLite3 development database Rails 5.0 on windows

I am trying to reset my development Database for my Rails 5.0 project on Windows, but when I run (same as rake db:drop)
rails db:drop
I get the following error:
Errno::EACCES Permission denied # unlink_internal
I restarted my PC already to make sure that rails was not running in anyway
You just need to exit the Rails Server.
I had the same error trying to reset my sqlite3 db on Windows, using rails 5.1.6 while doing the Learn Enough to Be Dangerous Rails tutorial. I found the following answer on another post, and it worked for me:
"For Dropping entire database just give rake db:setup it drops and again creates the database for you."
When I run the command, I get:
$ rails db:setup
Database 'db/development.sqlite3' already exists
Database 'db/test.sqlite3' already exists
-- create_table("users", {:force=>:cascade})
-> 0.0497s
-- create_table("users", {:force=>:cascade})
-> 0.0624s
And my database seems to work as expected, but with no data.
This can help
When I need to remove data base then I use rake db:reset.
Please try it.
Hope it helps.
Found Solution:
In windows machine you would have to specify that it is an unsafe move, so i
rake db:drop_unsafe
rails db:migrate
this is for windows machine, if you're using Linux then you can do just
rake db:reset

Running a Ruby on Rails Application from GitHub

I'm cloning a RoR app from Github. After the clone I install my gems. Now at this point my question/problem arises. Some research I've done suggests I do a
rake db:create
followed by a
rake db:migrate
I've tried both of those steps but am still having trouble.
When I run
rails console
and do something like Plan.first it returns nil. And when I try to visit my application I get an ActiveRecord::RecordNotFound in PagesController#home error alluding to the fact that it can't find the plan id of 1.
Any help is much appreciated.
Thanks in advance!
You have an empty database with no data in it, if seeds are provided - rake db:seed will help, otherwise you'll have to create initial data youself (in rails console, or may be directly in db)

sqlite3 won't go away....ruby on rails

I am trying to get rid of sqlite3 on my rails app and use postgres instead. I updated my gem file and removed it. manually uninstalled the sqlite3 gem. Got rid of it in my database.yml file. When I run rake db:create (As instructed on heroku) I get this:
db/development.sqlite3 already exists
I tried a whole bunch of rake commands and it continually refers to sqlite3. Why? I removed it? How do I remove it permanently from my app so I can go ahead and use postgres to deploy to heroku?
thank you so much itches head in mild frustration
This might be a sticky setting because spring is running. Did you try stopping spring?
spring stop

rails_sql_views prevents migrations on Heroku

I have a rails app that requires multi-table inheritance for which I am using the CITIER gem which itself requires the rails_sql_views gem to produce database views representing objects.
So far, so good. All this works like a charm on my local machine using sqlite3. When I try to deploy the application to Heroku, however, I am neither able to perform a database migration nor able to access the rails console.
The reason seems to be that the rails_sql_views gem tries to access some methods of PostgreSQLAdapter which are claimed to be non-existent. However, when I check the files of the rails repository, I can find these methods in the code. What is going on here?
When I try to run "heroku run rake db:migrate", I'll end up with the following error trace:
Running rake db:migrate --trace attached to terminal... up, run.1 rake aborted!
undefined method `tables' for class `ActiveRecord::ConnectionAdapters::PostgreSQLAdapter'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/core_ext/module/aliasing.rb:31:in `alias_method'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/core_ext/module/aliasing.rb:31:in `alias_method_chain'
/app/vendor/bundle/ruby/1.9.1/gems/rails_sql_views-0.8.0/lib/rails_sql_views/connection_adapters/postgresql_adapter.rb:5:in `included'
/app/vendor/bundle/ruby/1.9.1/gems/rails_sql_views-0.8.0/lib/rails_sql_views/loader.rb:12:in `include'
[....]
This looks like an incompatibility between sqlite3 and postgres adapters with that gem. You should try to keep development as close to production as possible. Try installing postgress locally https://devcenter.heroku.com/articles/local-postgresql and see if you get the same error locally. If you do, consider writing a detailed bug report and sending it to the author of the Gem, or attempt to fix it yourself and send a pull request.

How to connect to SQLServer 2k5 using Ruby 1.8.7 over W2k3 with active record 2.3.5

sorry for the blast.
I'm trying to connect to an SQLServer 2k5 using Ruby 1.8.7 over W2k3 with active record 2.3.5.
But, when I ran 'rake migrate' it throws the following:
rake migrate --trace
Hoe.new {...} deprecated. Switch to Hoe.spec.
Invoke migrate (first_time)
Invoke environment (first_time)
Execute environment
Execute migrate
rake aborted!
no such file to load -- odbc
(...)
C:/Program Files/test/Rakefile:146
(...)
So, my Rakefile in the line 146 says:
ActiveRecord::Migrator.migrate('db/migrate', ENV["VERSION"] ? ENV["VERSION"].to_i : nil )
The database.yml has been configured in so many ways without success. I've tried setup to mode in odbc, to configure a system dsn, to completely use the activerecord support for sqlserver but no success at all.
The same Rakefile works fine over Postgres and Oracle with the proper gems installed off course. But I cann't get this work.
Any help will be appreciated. Thanks in advance!
Ok, so I figured out.
The problem was on the missing ruby-odbc (currently version 0.9999), so, after the install of this gem all worked fine.
BUT, in one of my servers (the wich one that runs w2k8 server) I need to install the Ruby DevKit also (before the ruby-odbc gem)
That's odd.
Well. I hope that this can help someone else.
Cheers!

Resources