Skip to content

Instantly share code, notes, and snippets.

@laser
Last active January 4, 2016 09:29
Show Gist options
  • Save laser/8601951 to your computer and use it in GitHub Desktop.
Save laser/8601951 to your computer and use it in GitHub Desktop.
# app/controllers/calculation.rb
def create
req = ActiveSupport::JSON.decode(request.body)
calculator = StatefulCalculator.new
# to_crunch => [[1, 2, 3], [9, 10, 11]]
@sums = req["to_crunch"].map do |nums|
NumberCruncher.new(calculator).crunch(nums)
end
render :calculation_view
end
@ka8725
Copy link

ka8725 commented Jan 30, 2014

replace the req[“to_crunch”] with req[“arrays_to_crunch”] because in the blog it's explained as req[“arrays_to_crunch”]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment