Class: GeoLabels::RatingsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- GeoLabels::RatingsController
- Defined in:
- app/controllers/geo_labels/ratings_controller.rb
Instance Method Summary collapse
-
#get ⇒ Object
Still has no application.
-
#set ⇒ Object
PUT /geo-labels/ratings/set?record=GeoLabels::Contact&record_id=3&topic=food&value=7.
Methods inherited from ApplicationController
Instance Method Details
#get ⇒ Object
Still has no application
9 10 11 |
# File 'app/controllers/geo_labels/ratings_controller.rb', line 9 def get render plain: 'TODO app/controllers/geo_labels/ratings_controller.rb' end |
#set ⇒ Object
PUT /geo-labels/ratings/set?record=GeoLabels::Contact&record_id=3&topic=food&value=7
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/geo_labels/ratings_controller.rb', line 14 def set model = params[:record].safe_constantize return render plain: '', status: :unprocessable_entity unless model&.include?(GeoLabels::RatingsSupport) # 422 return render plain: '', status: :unprocessable_entity unless model..include? params[:topic].to_sym record = model.find(params[:record_id]) #TODO: add more sophisticated safeguard record.[params[:topic]] = params[:value] if record.save render plain: '' else render plain: '', status: :unprocessable_entity end end |