mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-01-24 01:07:52 -05:00
Removed JSON from classes that shouldn't have it. (PT: https://www.pivotaltracker.com/story/show/54570954) Also found a couple of controllers with broken authorization (i.e. not checking CanCan). Incidentally, this also fixes the comment form bug at https://www.pivotaltracker.com/story/show/54328716.
23 lines
795 B
Ruby
23 lines
795 B
Ruby
class OrderItemsController < ApplicationController
|
|
load_and_authorize_resource
|
|
|
|
# POST /order_items
|
|
def create
|
|
if params[:order_item][:price]
|
|
params[:order_item][:price] = params[:order_item][:price].to_f * 100 # convert to cents
|
|
end
|
|
@order_item = OrderItem.new(params[:order_item])
|
|
@order_item.order = current_member.current_order || Order.create(:member_id => current_member.id)
|
|
|
|
respond_to do |format|
|
|
if @order_item.save
|
|
format.html { redirect_to @order_item.order, notice: 'Added item to your order.' }
|
|
else
|
|
errors = @order_item.errors.empty? ?
|
|
"There was a problem with your order." : @order_item.errors.full_messages.to_sentence
|
|
format.html { redirect_to shop_path, alert: errors }
|
|
end
|
|
end
|
|
end
|
|
end
|