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 :)
Related
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.
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.
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?)
I am getting an ActiveRecord PGError on Heroku not locally. The error message from the Heroku Logs is:
ActiveRecord::StatementInvalid (PGError: ERROR: column items.user_id does not exist
LINE 1: SELECT "items".* FROM "items" WHERE ("items".user_id = 4) OR
This code works locally (SQLite) but not on Heroku (postgresql) so I have been reading about the differences. At first I thought that it was a case issue as I recognised that it should be User_ID -- but now I'm not sure, it's something about "items" that isn't quite right and I can't work out exactly what it is.
As I said this works absolutely fine on my local machine, it's only on heroku and postgres that the problem comes up.
Thanks in advance.
It appears that your database does not have the 'user_id' column in the items table. This could be because your migration has not been run recently, or perhaps you have edited an existing migration rather than making a new migration to add this column.
Do you care about your data on heroku at the moment? If not you can use Taps to take whatever you have in your local database and set Heroku's database to a (virtual) synchronized copy of it. On your local machine from your project's directory:
heroku db:push
This will wipe your heroku database so use this wisely.
Try restarting the app, using the following command:
heroku restart
It was a case issue after all - postgres does (I believe) a downcase on everything before sending it to the db -- my user_id was actually called, inexplicably, User_ID; after migration everything is working -- thanks to those that helped.
I seem to be getting a strange error when I run my tests in rails, they are all failing for the same reason and none of the online documentation seems particularly helpful in regards to this particular error:
SQLite3::SQLException: cannot rollback - no transaction is active
This error is crippling my ability to test my application and seems to have appeared suddenly. I have the latest version of sqlite3 (3.6.2), the latest sqlite3-ruby (1.2.4) gem and the latest rails (2.1.1).
Check http://dev.rubyonrails.org/ticket/4403 which shows a workaround. Could that be the problem you are encountering?
I had this problem once but with MySQL. Turned out I hadn't created the test database. Doh! Rails and sqlite creates them automatically I believe (at least it does in windows).
Are trying to do in memory testing? If not does the test database exist?
I got this error when running a test with the last statement being a click on a form submit. Once I did an assertion or should test, the test closed properly, and I didn't have to rerun the rake db:test:prepare
Thanks for the help. I actually ended up just deleting the rails folder and checking back out the last working copy from version control. I've made the identical changes and this problem hasn't reappeared, so either I messed up or rails had some sort of hiccup. Thankfully I had version control :-)