From d6562832e70d07e5013001b3bed43c1a66bb4074 Mon Sep 17 00:00:00 2001 From: David Gil Date: Thu, 10 Sep 2015 14:56:59 +0200 Subject: [PATCH] adds rinku gem and auto_link for Comment.body - WIP --- Gemfile | 3 ++- Gemfile.lock | 2 ++ app/models/comment.rb | 5 +++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 525d238fd..05d9ec2e9 100644 --- a/Gemfile +++ b/Gemfile @@ -29,7 +29,7 @@ gem 'omniauth-google-oauth2' gem 'kaminari' gem 'ancestry' gem 'acts-as-taggable-on' -gem "responders" +gem 'responders' gem 'foundation-rails' gem 'foundation_rails_helper' gem 'acts_as_votable' @@ -40,6 +40,7 @@ gem 'social-share-button' gem 'initialjs-rails', '0.2.0' gem 'unicorn' gem 'paranoia' +gem 'rinku', require: 'rails_rinku' gem 'savon' gem 'dalli' gem 'rollbar', '~> 2.2.1' diff --git a/Gemfile.lock b/Gemfile.lock index 7da5c9fe2..6dfcba2b0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -294,6 +294,7 @@ GEM http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 3.0) netrc (~> 0.7) + rinku (1.7.3) rollbar (2.2.1) rspec (3.3.0) rspec-core (~> 3.3.0) @@ -444,6 +445,7 @@ DEPENDENCIES quiet_assets rails (= 4.2.4) responders + rinku rollbar (~> 2.2.1) rspec-rails (~> 3.0) sass-rails (~> 5.0) diff --git a/app/models/comment.rb b/app/models/comment.rb index 233736824..586de729c 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -53,6 +53,11 @@ class Comment < ActiveRecord::Base self.user= author end + def body + unprocessed = super + unprocessed ? Rinku.auto_link(unprocessed).html_safe : unprocessed + end + def total_votes cached_votes_total end