Rails - Posting a Boolean (true or False) and updating the DB in the controller

Posted by AnApprentice on Stack Overflow See other posts from Stack Overflow or by AnApprentice
Published on 2010-12-29T21:49:03Z Indexed on 2010/12/29 21:54 UTC
Read the original article Hit count: 225

Hello, in my Rails 3 App, I'm posting with jQuery the following:

http://0.0.0.0:3000/topics/read_updater?&topic_id=101&read=true

In my controller:

  def read_updater
      current_user.topics.where(:topic_id => params[:topic_id]).update_all(:read => params[:read])

    render :json => {:status => 'success' }
  end

params[:conversation_id] works great, but params[:read] is inserting empty values in the DB, even though jQuery is posting either a true or false. Ideas? I want rails to update the DB with either true or false.

Thanks

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about ruby-on-rails