You're right to use validates_uniqueness_of :tmdb_id
in your Movie
model. You didn't show how you were saving the movies to your database, but .save
doesn't cause an exception when validations fail, whereas .save!
does. The key would be to use a save method that doesn't raise an error when validations fail.
Edit - Now that I understand what you're actually trying to do, you should be able to do something like:
per_page = 100
number_of_movies = Movie.count
page = number_of_movies/per_page+1
@movies = TmdbMovie.browse(:order_by => "release", :order => "asc", :page => page, :per_page => per_page, :language => "en", :expand_results => true) browses the oldest movies (:order_by => "release")
So if you've already pulled 435 movies, it'll only return movies 400-500 in the next call .. I did it this way because I wasn't sure if there was an offset
option, but if there is you could just offset the query by Movie.count
, which would be better.