Class: Voluntary::Api::V1::Things::ArgumentsController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- Voluntary::Api::V1::Things::ArgumentsController
- Includes:
- V1::BaseController
- Defined in:
- app/controllers/voluntary/api/v1/things/arguments_controller.rb
Instance Method Summary collapse
Methods included from V1::BaseController
#parent, #voluntary_application_javascripts, #voluntary_application_stylesheets
Instance Method Details
#comparison ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/controllers/voluntary/api/v1/things/arguments_controller.rb', line 10 def comparison = {} arguments = Argument.compare_two_argumentables(params[:argumentable_type], params[:side], params[:left_thing_name], params[:right_thing_name]). paginate(page: params[:page], per_page: 10) [:json] = arguments.map do |argument_comparison| hash = { left: { id: argument_comparison.id, value: argument_comparison.value }, right: { id: argument_comparison.right_id, value: argument_comparison.right_value }, topic: { id: argument_comparison.topic_id, name: argument_comparison.topic_name } } if params[:side] == 'right' left = hash[:left].clone right = hash[:right].clone hash[:left] = right hash[:right] = left end hash end [:meta] = { pagination: { total_pages: arguments.total_pages, current_page: arguments.current_page, previous_page: arguments.previous_page, next_page: arguments.next_page } } respond_with do |format| format.json { render } end end |