Created
November 19, 2012 20:09
-
-
Save joshwlewis/4113551 to your computer and use it in GitHub Desktop.
Revisions
-
joshwlewis created this gist
Nov 19, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ # app/validators/scss_format_validator.rb class ScssFormatValidator < ActiveModel::EachValidator def validate_each(object, attribute, value) begin # Attempt to parse SCSS Sass::Engine.new(value, syntax: :scss).render rescue Exception => e # Add error if parsing fails object.errors.add(attribute, :invalid_scss, error: e.inspect) end end end This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,4 @@ class Client < ActiveRecord::Base attr_accessible :style_text validates :style_text, scss_format: true end