settings say sqlite, connection says postgres - ruby-on-rails

Trying to figure out whats the deal with this.
Im using rails 7.0. Used rails a while back so not really too sure what im doing wrong.
The settings show its all pointing to Sqlite but its trying to connect to postgres.
I havent changed anything, rails new my_app and this is what I got.

I assume that you have the pg gem in your Gemfile and not the sqlite gem. Fix that and it will work.

Related

pdf.js gem producing errors

I am a rails novice and trying to create my web portfolio in Cloud9. I wanted to display my resume.pdf in the user browser so I installed this gem gem 'pdfjs_rails' now my app doesn't even start in cloud 9. It show the following error messages in the terminal:
Please help me. How can i revert it back? thanks
Doesn't look like anything related to pdfjs (no point in that direction). Are you sure you've selected the right runner in Cloud9? See:
https://community.c9.io/t/error-when-running-ruby-project/11799/4
More in general: if you think an issue would be related to a gem, you can simply remove it from the Gemfile and run gem bundle to 'revert' to a previous state.

Firebird database with rails app

When i execute rake db:schema:dump i get in schema.rb:
Could not dump table "xxx" because of following NoMethodError
undefined method `limit' for "INTEGER":String
This is problem with app because on new database i got this same error.
Im using flamerobin and i need to use it for creating db.
Im using https://github.com/rowland/activerecord-fb-adapter to connect to my db.
You're not the only one having this issue apparently: https://github.com/rowland/activerecord-fb-adapter/issues/67. Seems to be a gem issue.
Ok i just reinstall my ruby do everything from the begining (i need to move fbclient.dll from firebird install folder to Disk:ruby/bin) and now everything works great :)

switching from sqlite to postgres in rails app I´m working on

I am rather new to rails and I was thinking about how much trouble is it to switch from sqlite to postgres in an app that I´m currently working on. The thing is I have never switched in a middle of the building App process.
My local database has some data, but it is not relevant and may be deleted. I´m more concerned about the tables, columns, models, etc...
My reasons for the switch are:
I want to be able to use the 'groupdate' gem with my 'chartkick' gem in developement.
Later I will deploy to Heroku, I have done that before with adding 'pg' gem to production.
I have Postgres installed on my computer and I also have Postgres.app. I´ve been testing chartkick with groupdate in another project, so Postgres is not the problem.
So the question is basically, how much trouble is to switch from sqlite to PG in a middle of a project and what is the easiest and fastest way to do it?
sorry for the long text, hope someone reads it :)

Rails console can't connect to database

In last days i update my OS X to Maverics. Today when i try to create new project like this:
rails new abc
there were many problems but i install xcode and now it's work. Right now i open rails console like this:
rails console
and then whatever i write i only see:
Loading development environment (Rails 4.0.1)
1.9.3p448 :001 > Link
=> Link(no database connection)
What is wrong? Mysql is running, database exist. When i do rake db:migrate everything works fine.
The console probably does have a database connection but is reporting that it doesn't.
To see if that's true, make a query in the console.
Link.count
That fixed the false positive warning for me and a colleague.
In the past, referencing an ActiveRecord model immediately after loading the console would return its column information. Rails now only returns this information if it has been explicitly coerced to connect to the database by a method like connection, first, all, count, etc.
You can restore the previous behavior by adding this to your config/application.rb
console do
ActiveRecord::Base.connection
end
According to the issues #12804 on rails/rails.
The message just tells you that AR has not yet connected to the database and therefore does not know the column information. I think it's desired not to connect to the database unless we need to fetch data.
For now you could use Model.connection to establish a connection.
Try using reload! on the console and ensure that you have records in the specified model if not create records for the relations etc..
I had the same problem on ubuntu. I used reload! in rails console and added records in the database.
I'm having the same issue with Rails 4.0.1. It's occurring on the Linux server I'm deploying to as well as my Mavericks development machine.
The server works, specs work, but the console doesn't have a database connection.
Reverting to Rails 4.0.0 fixes the issue with the console.
I haven't found any other mention of this issue. There's probably an issue with the changes for 4.0.1 and the Postgres adapter, maybe? (Are you using Postgres?)

Rails - disable db connections

There's a Rails 3.2.3 web application which doesn't use any database. But in spite of that if I use the gem 'sqllite3' in GemFile I works perfect. But if I use gem 'pg' in that file it throws an error
ActiveRecord::ConnectionNotEstablished
Of course, I use different versions of database.yml when I use postgreSql or SqlLite3.
But I definitely don't use any database.
Why is it happening? What should I do to solve it? And how to disable using databases?
See the SO question here for how to bypass using a database. It's a little more work than just setting a flag.

Resources