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 8339735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:57:40+00:00 2026-06-09T04:57:40+00:00

I made an app with ror, the app works perfectly on local machine, but

  • 0

I made an app with ror, the app works perfectly on local machine, but when deployed it crashes
here is the relevant code for the controller

def index
  #debugger
  if @@first
    @ratings = []
    @@first=false
  end

@all_ratings = Movie.ratings_list

if params.has_key?:sort
  #debugger
  (params["rating_sort"].nil?)?(@ratings = []):(@ratings = params["rating_sort"])
  @movies = Movie.order(params[:sort]).find_all_by_rating(@ratings)       #:all,:conditions=>{"rating"=>@rating}, :order=>params[:sort])
  @sort = params[:sort]
else

   @ratings = params["ratings"].keys if params.has_key?"ratings"
   @movies = Movie.find_all_by_rating(@ratings)
end

end

here is the code for the view

%h1 All Movies
= form_tag movies_path, :method => :get do
 Include:
 -@all_ratings.each do |r|
  = r
  = check_box_tag "ratings[#{r}]","ratings[#{r}]", @ratings.include?(r)?true:false
 = submit_tag "Refresh" , :id=>"ratings_submit"

%table#movies
 %thead
  %tr
    %th{ :class => ( "hilite" if @sort=="title" ) }
      %a#title_header{:href =>movies_path({:sort => 'title',"rating_sort"=>@ratings})}  Movie Title
  %th Rating
  %th{:class=>("hilite" if @sort=="release_date")} 
    %a#release_date_header{ :href => movies_path({:sort => 'release_date',"rating_sort"=>@ratings}) }Release Date
  %th More Info
%tbody
- @movies.each do |movie|
  %tr
    %td= movie.title 
    %td= movie.rating
    %td= movie.release_date
    %td= link_to "More about #{movie.title}", movie_path(movie)
= link_to 'Add new movie', new_movie_path

Here is the error log from heroku

2012-08-06T12:32:01+00:00 app[web.1]: Started GET "/movies" for 111.68.102.115 at        2012-08-06 12:32:01 +0000
2012-08-06T12:32:01+00:00 app[web.1]:   Processing by MoviesController#index as HTML
2012-08-06T12:32:01+00:00 app[web.1]: Rendered movies/index.html.haml within layouts/application (1.2ms)
2012-08-06T12:32:01+00:00 app[web.1]:     5:     = r
2012-08-06T12:32:01+00:00 app[web.1]: Completed 500 Internal Server Error in 5ms
2012-08-06T12:32:01+00:00 app[web.1]:     6:     = check_box_tag "ratings[#{r}]","ratings[#{r}]", @ratings.include?(r)?true:false
2012-08-06T12:32:01+00:00 app[web.1]: 
2012-08-06T12:32:01+00:00 app[web.1]: ActionView::Template::Error (undefined method `include?' for nil:NilClass):
2012-08-06T12:32:01+00:00 app[web.1]:     3:   Include:
2012-08-06T12:32:01+00:00 app[web.1]:     8:   
2012-08-06T12:32:01+00:00 app[web.1]:     4:   -@all_ratings.each do |r|
2012-08-06T12:32:01+00:00 app[web.1]:     7:   = submit_tag "Refresh" , :id=>"ratings_submit"
2012-08-06T12:32:01+00:00 app[web.1]:     9: %table#movies
2012-08-06T12:32:01+00:00 app[web.1]:   app/views/movies/index.html.haml:6:in `block (2 levels) in _app_views_movies_index_html_haml___805194019313391138_23501340'
2012-08-06T12:32:01+00:00 app[web.1]:   app/views/movies/index.html.haml:4:in `each'
2012-08-06T12:32:01+00:00 app[web.1]:   app/views/movies/index.html.haml:4:in `block in _app_views_movies_index_html_haml___805194019313391138_23501340'
2012-08-06T12:32:01+00:00 app[web.1]:   app/views/movies/index.html.haml:2:in `_app_views_movies_index_html_haml___805194019313391138_23501340'
2012-08-06T12:32:01+00:00 app[web.1]: 
2012-08-06T12:32:01+00:00 app[web.1]: cache: [GET /movies] miss
2012-08-06T12:32:01+00:00 app[web.1]: 
2012-08-06T12:32:01+00:00 heroku[router]: GET cclpotatoes.herokuapp.com/movies dyno=web.1 queue=0 wait=0ms service=15ms status=500 bytes=728
  • 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-06-09T04:57:42+00:00Added an answer on June 9, 2026 at 4:57 am

    Let us assume you have a scenario where you don’t get the “sort” and “ratings” in params. This will result in

    @ratings = nil
    

    In the view page as you called the method include? over @ratings this throws this error.You might not tested this scenario in local.

    Below code will fix the error.

    if params.has_key?"ratings"
      @ratings = params["ratings"].keys 
    else
      @ratings = []
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I made an app that works on android 2.2 but will be used on
I have never made an app using XCode and Cocoa but I think following
I have a small ruby application that I made on my local machine. It
I made an app which implements a View.OnTouchListener . But when I uploaded it
So I recently made an .app wrapper for a zsh script, but when I
I just made my first setup of RoR, and creating a new application works
I made an app following these instructions http://www.ifans.com/forums/showthread.php?t=132024 And was great, but now, Now,
I made an app and testing it on an Android phone. But the controls
I made an app for parents to put on Their kids phones but need
I made an app using accelerometer but problem is whenever it detects rotation of

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.