samedi 24 octobre 2015

Rails - method not saving check_box_tag

I am continuing my project on the tmdb api and in the process of saving the result of my query. I created the method add_tmdb to handle this. As for my view, this is what I have:

= form_tag :action => 'add_tmdb' do
  ... stuff here
   %td= check_box_tag "movie_id[]", movie.id
 = submit_tag 'Add selected movie'

My controller is below:

def add_tmdb
    movie = {params[:movie_id] => :id}
    Movie.create!(movie)
    flash[:notice] = "#{params[:movie_id]} was successfully created."
    redirect_to movies_path
end

When I submit the record, I get an active record error. This is what I receive:

unknown attribute '["7555"]' for Movie.

Where do I need to make the change?

Thanks!

Aucun commentaire:

Enregistrer un commentaire