In a Rails 3.2.2 app running on Heroku Cedar stack with Postgres version 9.1.9.
While executing the following method:
class Post < ActiveRecord::Base
def shared_to_all
privacy & 1 == 1
end
end
I run into this error:
Completed 500 Internal Server Error in 19ms
NoMethodError (undefined method `&' for "0":String):
app/models/post.rb:75:in `shared_to_all'
app/controllers/application_controller.rb:212:in `next_post'
"privacy" is defined in the DDL of the heroku database as 'int4 DEFAULT 0'. The app works fine locally with the same rails framework/gems/database, and even when using heroku run console:
irb(main):008:0> Post.first.shared_to_all
=> false
irb(main):009:0> Post.first.privacy.class
=> Fixnum
irb(main):010:0> Post.first.privacy & 1 == 1
=> false