diff --git a/app/assets/javascripts/transactions.js b/app/assets/javascripts/transactions.js index 6ad3fc0..9e62a7c 100644 --- a/app/assets/javascripts/transactions.js +++ b/app/assets/javascripts/transactions.js @@ -78,7 +78,7 @@ ready = function() { $(flash_success).removeClass("hidden"); $(errors).addClass("hidden"); $(form)[0].reset(); - $('#transaction_creditor').select2('data', null); + $('#transaction_creditor').select2('val', null); }).on("ajax:error", function(xhr, status, error) { $(errors).removeClass("hidden"); $(panel_ul).empty(); diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 9a598e9..9c9b8f2 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -11,7 +11,7 @@ class ApplicationController < ActionController::Base end def authenticate_user_or_client! - current_user || current_client || head(:unauthorized) + current_user || current_client || redirect_to(root_path, flash: { notice: "You have been redirected." }) end def current_client diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 4abbcdb..652bf22 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -7,7 +7,7 @@ class UsersController < ApplicationController load_and_authorize_resource except: :show def show - @user = User.find_by_name(params[:id]) || User.new + @user = User.find_or_create_by(name: params[:id]) respond_to do |format| format.html { @transaction = Transaction.new } format.json { render json: @user } diff --git a/app/views/transactions/_new.html.haml b/app/views/transactions/_new.html.haml index d702df6..8738b17 100644 --- a/app/views/transactions/_new.html.haml +++ b/app/views/transactions/_new.html.haml @@ -14,5 +14,5 @@ %span.glyphicon.glyphicon-euro = f.number_field :euros, value: amount(@transaction.amount), placeholder: "Bedrag", step: 0.01, min: (0.01 unless current_user.penning), - class: "form-control", size: 20, required: true + class: "form-control", size: 20, max: 100, required: true = f.submit "Send it!", class: "pure-button pure-button-primary btn"