diff --git a/app/helpers/transactions_helper.rb b/app/helpers/transactions_helper.rb index 36098d1..704ea65 100644 --- a/app/helpers/transactions_helper.rb +++ b/app/helpers/transactions_helper.rb @@ -1,2 +1,5 @@ module TransactionsHelper + def amount a + a.zero? ? nil : number_with_precision(a/100.0, precision: 2) + end end diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 0f335a3..897b33c 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -14,8 +14,6 @@ - if current_user %li.pure-menu-item = 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 = link_to "Sign in", user_omniauth_authorize_path(:zeuswpi), class: "pure-menu-link" unless current_user .pure-u-1 diff --git a/app/views/transactions/_new.html.haml b/app/views/transactions/_new.html.haml index b47bc7a..06255ea 100644 --- a/app/views/transactions/_new.html.haml +++ b/app/views/transactions/_new.html.haml @@ -12,6 +12,6 @@ = f.text_field :message, required: true, placeholder: "Message", size: 75 %fieldset.pure-group-inline %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 = f.submit "Send it!", class: "pure-button pure-button-primary" diff --git a/config/routes.rb b/config/routes.rb index 3ac9949..7d6f8fa 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -5,6 +5,6 @@ Rails.application.routes.draw do root to: 'high_voltage/pages#show', id: "landing" - resources :transactions, only: [:new, :index, :create] + resources :transactions, only: [:index, :create] resources :users, only: [:show, :index] end