5
votes
4answers
1k views

How to add sequences to a migration and use them in a model?

I want to have a "Customer" Model with a normal primary key and another column to store a custom "Customer Number". In addition, I want the db to handle default Customer Numbers. I think, defining a ...
0
votes
1answer
86 views

What's the smarter option: Ruby logic or SQL function?

I needed to write a method that always returns an integer value. If the record is non-existent, the method returns 0 I have a unique index on the columns being queried and came up with two solutions: ...
0
votes
1answer
138 views

Rails 3.1 - Using Postgres in development -any way to get Git to handle DB migration states?

Heroku's decision to force Postgres use is giving me some major grief. After trying for a while to continue using SQLite in dev and Postgres in production/Heroku, I gave up and did as Heroku ...
1
vote
3answers
190 views

How to get the Sum of a Group of Records?

I am relatively new to rails and also sql. I am using postgres on production. I have a Like model and through polymorphism, it has attributes likeable_type and likeable_id, this is how items in my ...
2
votes
2answers
307 views

Factory_girl_rails and postgres date format?

How do I format a date to put it in a factory_girl_rails factory eg: Factory.define(:profile) do |t| t.length 110 t.shipdate 1993-04-06 end If it matters, I'm using postgressql and ...
1
vote
2answers
1k views

Heroku - Rails 3 to 3.1 migration issues with PosgreSQL: relation “users” does not exist

I have been following documents on how to move from Rails 3 to 3.1 and make it work on Heroku. I used the manual upgrade technique given here: http://webtempest.com/upgrade-rails-3-to-3-1/ I have ...
4
votes
2answers
293 views

Rails 3.1.0.rc4 + Postgres - cannot read from or write to database after reboot

I've just started to write an application using the latest version of Rails and PostgreSQL. I created the database, added required gem, configured database.yml file and started with two models - User ...