From 9edbdb7d553b925af55fdaa3a7448d8599e5cd37 Mon Sep 17 00:00:00 2001 From: jomo Date: Wed, 26 Aug 2015 02:54:51 +0200 Subject: [PATCH] add strip_attributes converts empty string to nil on the user model so unique indexes with null: true will not break --- Gemfile | 1 + Gemfile.lock | 3 +++ app/models/user.rb | 2 +- db/schema.rb | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 7d6f0ff..eac521d 100644 --- a/Gemfile +++ b/Gemfile @@ -6,6 +6,7 @@ gem 'mysql2' gem 'jquery-rails' gem 'bcrypt-ruby' # To use ActiveModel's has_secure_password gem 'sanitize' +gem 'strip_attributes' gem 'redcarpet', '~> 3.2.3' gem 'hirb' # pretty console output gem 'rb-readline' diff --git a/Gemfile.lock b/Gemfile.lock index b308c0c..705d8af 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -165,6 +165,8 @@ GEM colorize (>= 0.7.0) net-scp (>= 1.1.2) net-ssh (>= 2.8.0) + strip_attributes (1.5.1) + activemodel (>= 3.0, < 5.0) thor (0.19.1) thread_safe (0.3.3) tilt (1.4.1) @@ -207,6 +209,7 @@ DEPENDENCIES rest-client sanitize sass-rails + strip_attributes uglifier unicorn webrick diff --git a/app/models/user.rb b/app/models/user.rb index 8df5f04..16b5ecf 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -2,10 +2,10 @@ class User < ActiveRecord::Base include UsersHelper include ActionView::Helpers include Rails.application.routes.url_helpers + strip_attributes belongs_to :role - has_secure_password before_validation :strip_whitespaces, :set_uuid, :set_name, :set_email_token, :set_role diff --git a/db/schema.rb b/db/schema.rb index 47a3f72..0f9ed93 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150825232749) do +ActiveRecord::Schema.define(version: 20150826002927) do create_table "blogposts", force: true do |t| t.string "title"