From bb9d4bc371d10700730c58841b00615f39a4233d Mon Sep 17 00:00:00 2001 From: Ilion Beyst Date: Fri, 11 Sep 2015 14:51:35 +0200 Subject: [PATCH] friendly ids! --- Gemfile | 3 +++ Gemfile.lock | 3 +++ app/models/user.rb | 2 ++ app/views/users/show.html.haml | 2 +- 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 0c579b9..ad4169a 100644 --- a/Gemfile +++ b/Gemfile @@ -24,6 +24,9 @@ gem 'cancancan' # Haml for templating! gem "haml-rails", "~> 0.9" +# Friendly ids! +gem 'friendly_id', '~> 5.1.0' + # Pure for css gem 'purecss-rails' # Use datatables diff --git a/Gemfile.lock b/Gemfile.lock index ab5d11e..75530e1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -103,6 +103,8 @@ GEM multipart-post (>= 1.2, < 3) font-awesome-sass (4.4.0) sass (>= 3.2) + friendly_id (5.1.0) + activerecord (>= 4.0.0) globalid (0.3.6) activesupport (>= 4.1.0) haml (4.0.7) @@ -295,6 +297,7 @@ DEPENDENCIES factory_girl_rails faker font-awesome-sass + friendly_id (~> 5.1.0) haml-rails (~> 0.9) high_voltage (~> 2.4.0) jbuilder (~> 2.0) diff --git a/app/models/user.rb b/app/models/user.rb index c5886cf..54cfebb 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -11,6 +11,8 @@ # class User < ActiveRecord::Base + include FriendlyId + friendly_id :name, use: :finders devise :timeoutable, :omniauthable, :omniauth_providers => [:zeuswpi] has_many :incoming_transactions, class_name: 'Transaction', foreign_key: 'creditor_id' diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index 022c9bb..30a09a0 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -72,7 +72,7 @@ { targets: 1, render: function(data, type, full, meta) { - return data/100; + return (data/100).toFixed(2); } } ]