0

I have written a simple ruby on rails app and have added all the validations I want on the fields in it, except I want to add a validation that will reject entries that are in bad taste/intentionally meant to annoy others. I try to install the validates_not_profane plugin (https://github.com/michaeledgar/validates_not_profane), the install fails whether I follow the instructions on its documentation ($script/plugin install validates_not_profane ... if that fails script/plugin install git://github.com/michaeledgar/validates_not_profane.git) and the console rejects these commands. When researching why this failed, I found this and followed both of these instructions Confused about how to install Rails plugins), both of which also failed. When I install its only dependency, the profanalyzer gem from the console ($ gem install profanalyzer) before attempting to install validates_not_profane, the install is successful. I also copied and pasted in the gemfile: "

gem 'profanalyzer', '~> 1.2'

When I go into: models > concerns > forms.rb: I add the validation on the last line to the list of validations that have been tested and work, and when I run it and refresh the browser, I get the error code seen in the image:

class Form < ApplicationRecord
    validates :First_Name, presence: true
    validates :LastName, presence: true
    validates :Question1, presence: true
    validates :Question1, length: { in: 10 .. 500 }
    validates :age, :inclusion => { in: 18 .. 120 }
    validates_not_profane :First_Name   #   THIS IS WHERE I AM GETTING AN    
                                        #  UNINITIALIZED CONSTANT ERROR 

 [Error given from the line of code above][1]
end

Error given from the line of code above Even if I copied and pasted the code for the method validates_not_profane from the code on GitHub, I get the error code in the image:

What do i need to do to get this plugin installed and working?

I am running rails 5.0.0.1

Community
  • 1
  • 1
  • gems sometimes go out of date; if you can find a working gem that's great, but doing this from scratch might be a good learning excercise anyway. You can download a corpus of cuss words and then search the strings in a custom validation. – max pleaner Sep 30 '16 at 05:12

1 Answers1

0

From what I can see https://github.com/michaeledgar/validates_not_profane is quite old used in rails 2.x versions.

you could easily use this gem which supports rails 3 and above. Warning though it says it is not maintained anymore.

https://github.com/tjackiw/obscenity

Shani
  • 2,433
  • 2
  • 19
  • 23
  • Thank you. It sounds like I will have to try this one. I did see this one too, but opted for the other one because this one said it was not maintained, and the other had an active record validation built in it. Perhaps I will just attempt to write my own validation for this. Or just give up on this feature. – David W. Thrower Sep 30 '16 at 04:10