app/controllers/reviews_controller.rb
#ajax handler to make a review
ajax handler to make a review
ajax handler to make a review
def invite_handler 
    (action,event_id,critic_id) = params[:data].split(',')
    if (action == "i")
      review = Review.new({event_id: event_id, critic_id: critic_id, content: "", ratings: ""})
      if review.save
        render json: {action:"i", event_id: event_id, critic_id: critic_id}
      else
        render json: "error"
      end
    elsif (action == "u")
      review = Review.find_by(event_id: event_id, critic_id: critic_id)
      if review.destroy
        render json: {action:"u", event_id: event_id, critic_id: critic_id}
      else
        render json: "error"
      end
    end
  end
def invite_handler ( action , event_id , critic_id ) = params [ :data ] . split ( ',' ) if ( action == "i" ) review = Review . new ( { event_id : event_id , critic_id : critic_id , content : "" , ratings : "" } ) if review . save render json : { action : "i" , event_id : event_id , critic_id : critic_id } else render json : "error" end elsif ( action == "u" ) review = Review . find_by ( event_id : event_id , critic_id : critic_id ) if review . destroy render json : { action : "u" , event_id : event_id , critic_id : critic_id } else render json : "error" end end end
ajax handler to make a review
ajax handler to make a review
#not restful, not pretty. but works splendidly.