diff --git a/app/assets/stylesheets/purecss.css b/app/assets/stylesheets/purecss.css.scss similarity index 66% rename from app/assets/stylesheets/purecss.css rename to app/assets/stylesheets/purecss.css.scss index f6647f5..94150c8 100644 --- a/app/assets/stylesheets/purecss.css +++ b/app/assets/stylesheets/purecss.css.scss @@ -43,3 +43,23 @@ background-color: rgb(83, 180, 79); color: #fff; } + +fieldset.pure-group-inline { + display: inline-block; + .pure-group-addon { + padding: .5em .6em; + box-shadow: inset 0 1px 3px #ddd; + border: 1px solid #ccc; + white-space: nowrap; + border-collapse: separate; + margin-left: -4px; + &:last-child { + border-radius: 0 4px 4px 0; + } + &:first-child { + margin-left: 0; + border-radius: 4px 0 0 4px; + border-right: 0; + } + } +} diff --git a/app/assets/stylesheets/transactions.scss b/app/assets/stylesheets/transactions.scss index c402390..25d4ef0 100644 --- a/app/assets/stylesheets/transactions.scss +++ b/app/assets/stylesheets/transactions.scss @@ -1,3 +1,6 @@ // Place all the styles related to the transactions controller here. // They will automatically be included in application.css. // You can use Sass (SCSS) here: http://sass-lang.com/ +.price { + width: 100px; +} diff --git a/app/assets/stylesheets/users.scss b/app/assets/stylesheets/users.css.scss similarity index 83% rename from app/assets/stylesheets/users.scss rename to app/assets/stylesheets/users.css.scss index 1efc835..994acd2 100644 --- a/app/assets/stylesheets/users.scss +++ b/app/assets/stylesheets/users.css.scss @@ -1,3 +1,4 @@ // Place all the styles related to the users controller here. // They will automatically be included in application.css. // You can use Sass (SCSS) here: http://sass-lang.com/ +.euro:before { content:"\20AC"; } diff --git a/app/controllers/transactions_controller.rb b/app/controllers/transactions_controller.rb index c43728d..e4d1a0d 100644 --- a/app/controllers/transactions_controller.rb +++ b/app/controllers/transactions_controller.rb @@ -11,19 +11,16 @@ class TransactionsController < ApplicationController @transactions = Transaction.all end - def new - @transaction = Transaction.new - end - def create @transaction = Transaction.new(transaction_params) respond_to do |format| format.html do + @user = current_user if @transaction.save flash[:success] = "Transaction created" - redirect_to new_transaction_path + redirect_to current_user else - render 'new' + render "users/show" end end diff --git a/app/views/transactions/_new.html.haml b/app/views/transactions/_new.html.haml index 2c68b1d..b47bc7a 100644 --- a/app/views/transactions/_new.html.haml +++ b/app/views/transactions/_new.html.haml @@ -8,7 +8,10 @@ = f.select :creditor, options_from_collection_for_select(User.all.order(:name), :name, :name), { include_blank: true }, - { class: 'select2-selector', size: 50 } + { class: 'select2-selector', size: 50, required: true } = f.text_field :message, required: true, placeholder: "Message", size: 75 - = f.number_field :euros, value: (@transaction.amount.zero? ? nil : @transaction.amount/100), placeholder: "Bedrag", step: 0.01, min: 0.01 + %fieldset.pure-group-inline + %span.euro.pure-group-addon + = f.number_field :euros, value: (@transaction.amount.zero? ? nil : @transaction.amount/100), + placeholder: "Bedrag", step: 0.01, min: 0.01, class: "pure-group-addon price", size: 20, required: true = f.submit "Send it!", class: "pure-button pure-button-primary"