activerecord-sqlserver-adapter seems to have broken devise - ruby-on-rails

I have been working on a rails app for about 2 weeks that has worked fine every time I run it on my local machine. However, today I connected the app to sqlserver (instead of the default sqlite db) with the activerecord-sqlserver-adapter gem.
I was able to successfully connect to the db, but now I receive a undefined method 'email' for <User> on my DeviseSession#new page.
Does anyone know why changing db adapters would cause devise to break?

Because you did not migrate the database after switching the adapter, so the attribute does not exist.

The issue was that I set the table names within my models and forgot their schema prefix.

Related

Heroku PostgreSQL Database - inconsistent enties

i'm working on a Ruby on rails project adopted by another developer. It's deployed on heroku, uses heroku postgreSQL.
When i run the project on my local rails server with the remote database, it works fine. But there is one problem: I would like to delete some entries. So I tried to connect via PostgreSQL-Console. But it seems like the PostgrqSQL-Console gives me another version of the database than the one who is used by the app.
For example, the latest user ID in the app is 540 and in the database displayed by the console only 500.
Any idea? Thank you in advance.
Problem is solved. The elastic search index wasn't synchronized. Thank you for your help anyway.

Everything works except rails console after moving to Postgresql on Cloud9

I've moved my development environment from sqlite to postgresql on Cloud9 IDE, following this post Cloud9 postgres.
Now just about everything works,
created a new db
migrated table changes
saved data to db with rake tasks
rendered data from the db in views
But when I run rails c and try and load data there, it fails.
Item
=> Item (call 'Item.connection' to establish a connection)
Item.all
=> PG::ConnectionBad: fe_sendauth: no password supplied
I don't think its actually a no password issue because in every other way I can access and work with the database... just not in rails console.
Does maybe something need to be done to setup a new connection here?
the main issue is POSTGRES need a role to be setup , no doubt the app must be working fine, but when u type in rails c , the control access the schema file and tries to load all the table, here the table ITEM must be the first one to be read by control.
all you need to do is create a role in postgres as superuser and type in its credentials in database.yml.
let me know if this works

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 :)

Database attribute saving in Development but not in Production

I'm getting a database error in production. But in development no error.
ActiveModel::MissingAttributeError (can't write unknown attribute `invited_by_id`):
invited_by_id is a column added by the Devise Invitable gem to my User table. I encountered this error after pushing my Devise Invitable implementation to production for the first time and then attempting to invite a new user.
I have confirmed that invited_by_id IS present in both my development and production tables. I have checked this multiple times via Rails console for each environment. I have also done rake db:migrate twice for good measure (in production) with the first time adding the Devise Invitable columns and the second time, of course, having no new migrations to run since the columns were already added. There are also numerous other columns added by Devise Invitable to the same User table that were successfully migrated and are not creating errors. I have successfully edited one as well. (Google Searches, Devise Invitable Github issues, and a thorough review of my development and production environment fields have yielded nothing but encouragement to check that the column is present -- which it is.)
Is there something to be aware of with Devise Invitable, User tables, or with development versus production databases for a situation like this? For some additional context, I am using Devise Invitable 1.5.5, Rails 4.2.4, and my production database is on Heroku.
Thank you!
ActiveModel::MissingAttributeError (can't write unknown attribute `invited_by_id`)
Looking at this error message, you are missing invited_by_id column in your production database. Make sure you run your migrations on production environment and try again. That should fix your problem.
Here is the same issue reported on the gem's github page.
You can also try restarting your heroku app which seems to fix this type of issues many times :)

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?)

Resources