Continuing my project on themoviedb api, here is now what I have. I added a method to pass the attributes of the query. My method is:
def tmdb_search
params.require(:tmdb_ids).permit(:id, :title, :release_date)
end
I pass this to:
def create_from_tmdb(tmdb_search)
tmdb_search = params[:tmdb_ids]
@movie = Tmdb::Movie.find(tmdb_search)
end
I proceed then in adding the movie to my db:
def add_tmdb(create_from_tmdb)
create_from_tmdb = (params[:tmdb_ids])
@movie = Movie.new(create_from_tmdb)
@movie.save
redirect_to movies_path
end
When I trying adding it, I get the wrong number of arguments (0 for 1)
for the line def add_tmdb(create_from_tmdb)
.
The overall goal is to pass the result of my TMDB movie query from the view via check_box_tag, then saving it to my db. Here is the associated view:
- @movie.each do |movie|
%tr
%td= movie.title
%td= movie.release_date
%td= check_box_tag 'tmdb_ids[]', movie.id
= submit_tag 'Add selected movie'
= link_to 'Return to movie list', movies_path
Aucun commentaire:
Enregistrer un commentaire