From 3ec19abab334fd6f06a4574a6f88aba7ca8fcbd7 Mon Sep 17 00:00:00 2001 From: benji Date: Fri, 11 Sep 2015 15:50:07 +0200 Subject: [PATCH] diefstal is een misdrijf --- app/controllers/application_controller.rb | 2 +- app/controllers/transactions_controller.rb | 9 ++------- app/views/partials/_form_errors.html.haml | 2 +- app/views/transactions/_new.html.haml | 9 +++------ 4 files changed, 7 insertions(+), 15 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index fa00f9f..b126fc6 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -5,7 +5,7 @@ class ApplicationController < ActionController::Base rescue_from CanCan::AccessDenied do |exception| respond_to do |format| - format.json { render nothing: true, status: :forbidden } + format.json { render json: [ "Diefstal is een misdrijf." ], status: :forbidden } format.html { redirect_to root_url, alert: exception.message } end end diff --git a/app/controllers/transactions_controller.rb b/app/controllers/transactions_controller.rb index dfb950a..f4c1e54 100644 --- a/app/controllers/transactions_controller.rb +++ b/app/controllers/transactions_controller.rb @@ -10,16 +10,11 @@ class TransactionsController < ApplicationController @transactions = Transaction.all end - def new - @transaction = Transaction.new - end - def create - transaction = Transaction.new(transaction_params) - if transaction.save + if @transaction.save head :created else - render json: transaction.errors.full_messages, status: :unprocessable_entity + render json: @transaction.errors.full_messages, status: :unprocessable_entity end end diff --git a/app/views/partials/_form_errors.html.haml b/app/views/partials/_form_errors.html.haml index 05d83db..019c18c 100644 --- a/app/views/partials/_form_errors.html.haml +++ b/app/views/partials/_form_errors.html.haml @@ -1,4 +1,4 @@ -#transaction_errors.panel.panel-error.hidden +#transaction_errors.panel.panel-danger.hidden .panel-heading %h3.panel-title This transaction could not be saved. diff --git a/app/views/transactions/_new.html.haml b/app/views/transactions/_new.html.haml index 56947e0..37a7d02 100644 --- a/app/views/transactions/_new.html.haml +++ b/app/views/transactions/_new.html.haml @@ -7,15 +7,12 @@ = f.select :creditor, options_from_collection_for_select(User.all.order(:name), :name, :name), { include_blank: true }, - { class: 'select2-selector form-control', size: 50 } - -# { class: 'select2-selector', size: 50, required: true } - = f.text_field :message, placeholder: "Message", size: 75, class: "form-control" - -# = f.text_field :message, required: true, placeholder: "Message", size: 75 + { class: 'select2-selector form-control', size: 50, required: true } + = f.text_field :message, placeholder: "Message", size: 75, class: "form-control", required: true .input-group %span.input-group-addon %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 - -# placeholder: "Bedrag", step: 0.01, min: 0.01, class: "pure-group-addon price", size: 20, required: true + class: "form-control", size: 20, required: true = f.submit "Send it!", class: "pure-button pure-button-primary"