vendredi 23 octobre 2015

Working on tmdb api on rails

I am continuing my journey in learning ruby and rails. I am currently working with the tmdb gem and trying to access and then return the results of my query.

In my MovieController, I have two methods: search_tmbd and lookup_tmdb. Here is what I have:

def search_tmdb
  #@movie = Tmdb::Movie.find(params[:search])
  @movie = Tmdb::Movie.lookup_tmdb(params[:search])
end

def self.lookup_tmdb(title)
  title = params[:search]
  @movie = Tmdb::Movie.find(title)

The user inputs the query in :search. When I do the query, I get this error:

undefined method `lookup_tmdb' for Tmdb::Movie:Class. I understand I may need to pass the values in an array, but how do I work this? This one below works for me in method search_tmdb and returns the title of the movie.

@movie = Tmdb::Movie.find(params[:search])

Aucun commentaire:

Enregistrer un commentaire