Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6995365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:00:47+00:00 2026-05-27T20:00:47+00:00

I have an app I am deploying to Heroku. Everything seems to work besides

  • 0

I have an app I am deploying to Heroku. Everything seems to work besides the “show” action for my User model.

Here is my code for the user model (what’s relevant, anyway)

class User < ActiveRecord::Base

  attr_accessor :password
  attr_accessible :username, :email, :password, 
                  :password_confirmation, :confirmed, 
                  :school_id, :graduation, 
                  :admin, :stars, :credits, :school_name

  has_many :uploads, :dependent => :destroy
  belongs_to :school
  has_many :downloads, :source => :user_id, :dependent => :destroy
  has_many :comments, :dependent => :destroy

  #VALIDATIONS OMITTED

  #WARNING
  before_create :encrypt_password

  #PASSWORD ENCRYPTION METHOD OMITTED

  #getter for school name
  def school_name
    school.name if school
  end

  #setter for school name (will create school if it didn't find one)
  def school_name=(name)
    self.school = School.find_by_name(name) unless name.blank?
  end

  def add_credits(num)
    self.credits += num
  end

  def charge
    self.credits -= 1
    self.save(false)
  end

  def has_downloaded?(file)
    @downloads = self.downloads.find(:all, :conditions => "upload_id = #{file.id}")
    return (@downloads.length > 0)
  end


  private

    #MORE PASSWORD ENCRYPTION LOGIC

end

Here is the code for my upload model:

class Upload < ActiveRecord::Base
    default_scope :order => 'uploads.created_at DESC'

    attr_protected :linked_file_name, :linked_content_type, :linked_size

    attr_accessible :user_id, :stars, :ratings, 
                    :semester, :professor, :year, 
                    :description, :course_id, :school_id

    after_save :set_course_school

    belongs_to :user
    belongs_to :school
    belongs_to :course
    has_many :downloads, :source => :upload_id, :dependent => :destroy
    has_many :comments, :foreign_key => "file_id", :dependent => :destroy
    #belongs_to :class

    #paperclip
    has_attached_file :linked,
          :storage => :s3,
          :s3_credentials => "#{RAILS_ROOT}/config/s3.yml",
          :path => ":class/:id/:attachment/:basename.:extension"

    #validations
    validates :school_id, :presence => true

    def update_rating
      @comments = self.comments.all
      if @comments.length > 0
        @stars = 0
        @comments.each do |comment|
          @stars += comment.rating
        end
        self.stars = @stars
        self.ratings = @comments.length
      end
      self.save(false)
    end

    def course_name
      return [course.subject, course.course_code].join(' ') if course
    end

    def course_name=(name)
      @split = name.split(' ', 2)
      @subject = @split.first
      @course_code = @split.last

      @conditions = {
        :subject => @subject,
        :course_code => @course_code,
        :school_id => self.school_id
      }

      self.course = Course.find(:first, :conditions => @conditions) || Course.create(@conditions)
    end

    def set_course_school
      course.set_school
    end

end

And here is the controller action:

  def show
    @user = User.find(params[:id])
    @uploads = @user.uploads.all
    @downloads = @user.downloads.all
  end

Heroku seems to be having some problem with the statement @user.uploads.all which works fine locally, here is what the logs give me:

2011-12-29T21:57:07+00:00 app[web.1]: Started GET "/users/1" for 200.88.103.28 at 2011-12-29 13:57:07 -0800
2011-12-29T21:57:07+00:00 app[web.1]:   Processing by UsersController#show as HTML
2011-12-29T21:57:07+00:00 app[web.1]:   Parameters: {"id"=>"1"}
2011-12-29T21:57:07+00:00 app[web.1]: Completed   in 10ms
2011-12-29T21:57:07+00:00 app[web.1]: 
2011-12-29T21:57:07+00:00 app[web.1]: ActiveRecord::StatementInvalid (PGError: ERROR:  operator does not exist: character varying = integer
2011-12-29T21:57:07+00:00 app[web.1]: : SELECT     "uploads".* FROM       "uploads"  WHERE     ("uploads".user_id = 1) ORDER BY  uploads.created_at DESC):
2011-12-29T21:57:07+00:00 app[web.1]:                                                              ^
2011-12-29T21:57:07+00:00 app[web.1]:   app/controllers/users_controller.rb:21:in `show'
2011-12-29T21:57:07+00:00 app[web.1]: HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.
2011-12-29T21:57:07+00:00 app[web.1]: LINE 1: ...ROM       "uploads"  WHERE     ("uploads".user_id = 1) ORDER...

Any ideas? I imagine the fix is super simple. What’s weird is that I have another Heroku deployed app that uses the exact same user logic (has a show page that gets all the ‘posts’ of a user) and that works fine. The code looks almost identical…

I would greatly appreciate a solution to this problem. I wish I could offer a bounty but I used most of my rep on a big bounty on an Android question.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:00:48+00:00Added an answer on May 27, 2026 at 8:00 pm

    From the error statement, it looks like the user_id column on your uploads table is a varchar, not an integer. Postgres (used by Heroku) doesn’t automatically cast, as far as I know.

    Can you confirm the data types?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Rails 3.2 app that I'm deploying on the Heroku Cedar stack.
I have a rails 3.2 app on heroku. I have tried everything I can
We have a web-app, that we're deploying to a remote Ubuntu server. The app
I have a problem deploying Qt frameworks with my Mac app, and I hope
I have a Google Web Toolkit application that I am deploying to Google App
Deploying on JBoss AS 7.1.0.Final. I have a very simple test app. It was
I'm deploying a Rails app on Heroku (for now) via git, and would also
I am deploying an app to heroku and the app is on rails 3.2
When deploying a clojure app to Heroku, I see it is using cached Leiningen
I have an app and need for deploying to customers. to check in the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.