SitePoint Sponsor

User Tag List

Results 1 to 14 of 14
  1. #1
    SitePoint Zealot mrtopher's Avatar
    Join Date
    Mar 2004
    Location
    VA
    Posts
    150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question I need help with this ruby on rials error

    I am running RoR on my local computer and things have been working just fine until I began getting a strange error. I use WEBrick as the local server. When I start the server, I can work for about ten minutes until I get this error on any page I view:

    WARNING: You have a nil object when you probably didn't expect it! Odds are you
    want an instance of Array instead.

    Look in the callstack to see where you're working with an object that could be nil.
    Investigate your methods and make sure the object is what you expect!
    : SELECT COUNT(*) FROM products
    Then, if I refresh the page I get this error:

    Invalid argument: SELECT COUNT(*) FROM products
    Everything goes back to normal if I restart WEBrick, but then it all starts over again ten minutes later.

    Can anyone tell me whats going on??

  2. #2
    throw me a bone ... now bonefry's Avatar
    Join Date
    Nov 2004
    Location
    Romania
    Posts
    848
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    can you give us your code please ?

  3. #3
    SitePoint Zealot mrtopher's Avatar
    Join Date
    Mar 2004
    Location
    VA
    Posts
    150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, thats just it. The code works fine (for about ten minutes or so) and then I get my error (it's a scaffold, so I would assume that it's fine). It happens with any and all code in the program. So I think it might be a problem with WEBrick and not my code, but I don't know.

    Controller:
    Code:
    class AdminController < ApplicationController
      def index
        list
        render :action => 'list'
      end
    
      def list
        @product_pages, @products = paginate :product, :per_page => 10
      end
    
      def show
        @product = Product.find(params[:id])
      end
    
      def new
        @product = Product.new
      end
    
      def create
        @product = Product.new(params[:product])
        if @product.save
          flash[:notice] = 'Product was successfully created.'
          redirect_to :action => 'list'
        else
          render :action => 'new'
        end
      end
    
      def edit
        @product = Product.find(params[:id])
      end
    
      def update
        @product = Product.find(params[:id])
        if @product.update_attributes(params[:product])
          flash[:notice] = 'Product was successfully updated.'
          redirect_to :action => 'show', :id => @product
        else
          render :action => 'edit'
        end
      end
    
      def destroy
        Product.find(params[:id]).destroy
        redirect_to :action => 'list'
      end
    end

  4. #4
    SitePoint Enthusiast
    Join Date
    Sep 2004
    Location
    UK
    Posts
    78
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What version of Ruby are you running? I have had some unusual problems with Rails in the past that have been down to having an old version of Ruby installed (such as you might get installed with your OS).

  5. #5
    SitePoint Zealot mrtopher's Avatar
    Join Date
    Mar 2004
    Location
    VA
    Posts
    150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am running the latest and greatest (0.13 I think).

  6. #6
    SitePoint Enthusiast
    Join Date
    Sep 2004
    Location
    UK
    Posts
    78
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    mrtopher,

    I was referring to your version of Ruby, not Ruby on Rails. If your version of Ruby is quite old, consider upgrading and see what happens. I can't see anything obvious which could cause that problem.

    Here's a link to download Ruby: http://www.ruby-lang.org/en/20020102.html

    Have you tried the RoR IRC channel? They're usually very helpful there.

  7. #7
    Internet Evangelist bweeb's Avatar
    Join Date
    Jun 2005
    Location
    USA
    Posts
    525
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Did that do the trick?
    CEO of Site5 Web Hosting - 18 Locations around the world, 45,000+ happy customers!
    WebPub.com - Automatic WordPress Upgrades (New Startup)

  8. #8
    SitePoint Zealot mrtopher's Avatar
    Join Date
    Mar 2004
    Location
    VA
    Posts
    150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, I have the latest version of Ruby running on my machine and I am still having problems.

    I am going to see if anyone can help me in the IRC chat. But please post any other ideas you might have.

  9. #9
    Internet Evangelist bweeb's Avatar
    Join Date
    Jun 2005
    Location
    USA
    Posts
    525
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Might try installing Apache and doing it through there to see if the same problem comes up...
    CEO of Site5 Web Hosting - 18 Locations around the world, 45,000+ happy customers!
    WebPub.com - Automatic WordPress Upgrades (New Startup)

  10. #10
    SitePoint Zealot mrtopher's Avatar
    Join Date
    Mar 2004
    Location
    VA
    Posts
    150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am looking at the WEBrick callstack and after five to ten minutes I am getting an internal server error (500). I even tried changing the default port to something different and I am still having problems.

  11. #11
    SitePoint Enthusiast
    Join Date
    Sep 2004
    Location
    UK
    Posts
    78
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Did you try the guys on IRC?

  12. #12
    SitePoint Zealot mrtopher's Avatar
    Join Date
    Mar 2004
    Location
    VA
    Posts
    150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy

    I did and they were unable to help me. I believe it is a problem with WEBrick, but I can't seem to find any additional help or places to go and ask.

  13. #13
    SitePoint Enthusiast
    Join Date
    Sep 2004
    Location
    UK
    Posts
    78
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To try and isolate the source of your problem to your machine, you could try:

    Running up Rails + your application using a Linux live CD such as Knoppix,
    Get a hosting account at a Rails-friendly host such as Textdrive, and get it going there,
    Install on a friend's machine maybe?

    Alternatively you could do a full uninstall/reinstall of both Ruby and Rails.

    What platform are you running on? I know that Rails is partially broken on OSX, particualrly Tiger.

    Sorry if the above is all a bit obvious, it just seems like you may have an isolated environment problem since nobody else seems to be having this difficulty.

  14. #14
    SitePoint Member
    Join Date
    Aug 2005
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm getting the same error on:
    XP, latest ruby, rails 0.13.1,MySQL 4.12
    Webrick

    Win2k, latest ruby, rails 0.13.1,MySQL 4.12
    Webrick & Apache

    There is a wiki on this but it hasn't helped me:
    http://wiki.rubyonrails.com/rails/sh...access+problem

    My code is fine and the problem is intermittent. Seems like webrick can't communicate with mysql.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •