Fix display correct amount in transaction form

This commit is contained in:
benji 2015-09-10 16:45:44 +02:00
parent 079c1ea4d0
commit b55eb68118
4 changed files with 5 additions and 4 deletions

View file

@ -1,2 +1,5 @@
module TransactionsHelper module TransactionsHelper
def amount a
a.zero? ? nil : number_with_precision(a/100.0, precision: 2)
end
end end

View file

@ -14,8 +14,6 @@
- if current_user - if current_user
%li.pure-menu-item %li.pure-menu-item
= link_to current_user.name.capitalize, current_user, class: "pure-menu-link" = link_to current_user.name.capitalize, current_user, class: "pure-menu-link"
%li.pure-menu-item
= link_to "New Transaction", new_transaction_path, class: "pure-menu-link"
- else - else
= link_to "Sign in", user_omniauth_authorize_path(:zeuswpi), class: "pure-menu-link" unless current_user = link_to "Sign in", user_omniauth_authorize_path(:zeuswpi), class: "pure-menu-link" unless current_user
.pure-u-1 .pure-u-1

View file

@ -12,6 +12,6 @@
= f.text_field :message, required: true, placeholder: "Message", size: 75 = f.text_field :message, required: true, placeholder: "Message", size: 75
%fieldset.pure-group-inline %fieldset.pure-group-inline
%span.euro.pure-group-addon %span.euro.pure-group-addon
= f.number_field :euros, value: (@transaction.amount.zero? ? nil : @transaction.amount/100), = f.number_field :euros, value: amount(@transaction.amount),
placeholder: "Bedrag", step: 0.01, min: 0.01, class: "pure-group-addon price", size: 20, required: true 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" = f.submit "Send it!", class: "pure-button pure-button-primary"

View file

@ -5,6 +5,6 @@ Rails.application.routes.draw do
root to: 'high_voltage/pages#show', id: "landing" root to: 'high_voltage/pages#show', id: "landing"
resources :transactions, only: [:new, :index, :create] resources :transactions, only: [:index, :create]
resources :users, only: [:show, :index] resources :users, only: [:show, :index]
end end