Rails - continuing to work on check_box_tag

丶灬走出姿态 提交于 2020-02-06 08:48:26

问题


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

来源:https://stackoverflow.com/questions/33331649/rails-continuing-to-work-on-check-box-tag

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!