NoMethodError (undefined method `sismember' for nil:NilClass)…Trying to deploy on heroku

I get the following error:

2015-05-17T17:25:40.349230+00:00 app[web.1]: Started GET “/movies/1” for at 2015-05-17 17:25:40 +0000
2015-05-17T17:25:40.423697+00:00 app[web.1]: Completed 500 Internal
Server Error in 67ms
2015-05-17T17:25:40.355931+00:00 app[web.1]: Processing by
MoviesController#show as HTML
2015-05-17T17:25:40.425095+00:00 app[web.1]:
2015-05-17T17:25:40.406984+00:00 app[web.1]: Movie Load (2.4ms)
SELECT “movies”.* FROM “movies” WHERE “movies”.“id” = $1 LIMIT 1
[[“id”, 1]]
2015-05-17T17:25:40.425098+00:00 app[web.1]: NoMethodError (undefined
method sismember' for nil:NilClass): 2015-05-17T17:25:40.425100+00:00 app[web.1]: app/models/movie.rb:20:incart_action’
2015-05-17T17:25:40.425102+00:00 app[web.1]:
2015-05-17T17:25:40.425101+00:00 app[web.1]:
app/controllers/movies_controller.rb:9:in show' 2015-05-17T17:25:40.425104+00:00 app[web.1]: 2015-05-17T17:25:41.951208+00:00 heroku[router]: at=info method=GET path="/movies/4" request_id=cbb36b63-06ee-4da0-992d-6d512d431ea4 fwd="" dyno=web.1 connect=0ms service=17ms status=500 bytes=1714 2015-05-17T17:25:41.932183+00:00 app[web.1]: Started GET "/movies/4" for at 2015-05-17 17:25:41 +0000 2015-05-17T17:25:41.941428+00:00 app[web.1]: Completed 500 Internal Server Error in 5ms 2015-05-17T17:25:41.935883+00:00 app[web.1]: Processing by MoviesController#show as HTML 2015-05-17T17:25:41.935891+00:00 app[web.1]: Parameters: {"id"=>"4"} 2015-05-17T17:25:41.939396+00:00 app[web.1]: Movie Load (2.2ms) SELECT "movies".* FROM "movies" WHERE "movies"."id" = $1 LIMIT 1 [["id", 4]] 2015-05-17T17:25:41.944520+00:00 app[web.1]: 2015-05-17T17:25:41.944523+00:00 app[web.1]: NoMethodError (undefined methodsismember’ for nil:NilClass):
2015-05-17T17:25:41.944525+00:00 app[web.1]: app/models/movie.rb:20:in
cart_action' 2015-05-17T17:25:41.944526+00:00 app[web.1]: app/controllers/movies_controller.rb:9:inshow’
2015-05-17T17:25:41.944528+00:00 app[web.1]:
2015-05-17T17:25:41.944529+00:00 app[web.1]:

movie.rb (model)

class Movie < ActiveRecord::Base
has_many :purchases
has_many :buyers, through: :purchases

before_save :embed_video_url

def poster{poster_url}

def imdb{imdb_id}/

def embed_video_url
self.video_url =

def cart_action(current_user_id)
if $redis.sismember “cart#{current_user_id}”, id
“Remove from”
“Add to”


class MoviesController < ApplicationController

def index
@movies = Movie.all

def show
@movie = Movie.find(params[:id])
@cart_action = @movie.cart_action current_user.try :id


The weird about this error is that the application run without any
problem locally but when I deployed to heroku I can see the first page
but when I click to a movie or trying to log in i get error.

Any help?

On Sunday, 17 May 2015 15:08:07 UTC-4, User wrote:

2015-05-17T17:25:40.406984+00:00 app[web.1]: Movie Load (2.4ms)
2015-05-17T17:25:41.951208+00:00 heroku[router]: at=info method=GET
2015-05-17T17:25:41.939396+00:00 app[web.1]: Movie Load (2.2ms)
2015-05-17T17:25:41.944529+00:00 app[web.1]:{poster_url}

@cart_action = @movie.cart_action current_user.try :id

You did not include the code that sets $redis, and I suspect that’s
the problem is. Connecting to Redis on Heroku may be slightly different
that local, since dynos are not guaranteed to continue existing between

–Matt J.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs