Make quick pay reload, the good way

This commit is contained in:
tl3ilaxu 2016-03-03 22:20:56 +01:00
parent 0ecde8201e
commit f3669117a2
2 changed files with 11 additions and 8 deletions

View file

@ -42,7 +42,10 @@ class UsersController < ApplicationController
order = @user.orders.build
order.order_items.build(count: 1, product: @user.dagschotel)
if order.save
render json: { message: "Quick pay succeeded for #{@user.name}." }, status: :ok
respond_to do |format|
format.html { redirect_to(@user) }
format.json { render json: { message: "Quick pay succeeded for #{@user.name}." }, status: :ok }
end
else
head :unprocessable_entity
end
@ -50,11 +53,11 @@ class UsersController < ApplicationController
private
def user_params
params.fetch(:user, {}).permit(:avatar, :private, :dagschotel_id)
end
def user_params
params.fetch(:user, {}).permit(:avatar, :private, :dagschotel_id)
end
def init
@user ||= current_user
end
def init
@user ||= current_user
end
end

View file

@ -19,7 +19,7 @@
%p.center
%b or
-#%button.btn.btn-default.product{ data: { product: @user.dagschotel} }
= link_to quickpay_user_path(@user), remote: true, data: { quickpay: true, type: "json" }, id: "dagschotel_quickpay", class: "btn btn-default btn-block" do
= link_to quickpay_user_path(@user), data: { quickpay: true, type: "json" }, id: "dagschotel_quickpay", class: "btn btn-default btn-block" do
%p.center Order dagschotel
= image_tag @user.dagschotel.avatar, title: "Huidige dagschotel"
= render 'errors', object: @user