let's chat real-time

http://www.flowdock.com/invitations/e8f998953d3ea1d8895d0432d1df742e22caaa38


On Sun, Apr 20, 2014 at 11:54 AM, Justin Gordon <notifications@github.com>wrote:

> In app/models/micropost.rb:
>
> > @@ -22,4 +23,37 @@ def self.from_users_followed_by(user)
> >      where("user_id IN (#{followed_user_ids}) OR user_id = :user_id",
> >            user_id: user.id
> )
> >    end
> > +
> > +  # return array of profane words in content or nil if none
> > +  def profane_words_in_content
> > +    # Better to set this somewhere configurable. Placing here for example purposes.
> > +    profane_words = %w(poop fart fartface poopface poopbuttface)
> > +    content_words = content.split(/\W/)
> > +    content_words.select { |word| word.in? profane_words }.presence
> > +  end
> > +
> > +  # This could have been done with and after_save hook, but it seems wrong to ever be sending
> > +  # emails from after_save.
> > +  # Return true if save successful
> > +  def save_with_profanity_callbacks
>
> I really don't like hooking into save anything that does things like sends
> notifications.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/justin808/fat-code-refactoring-techniques/pull/15/files#r11798405>
> .
>



-- 


--
James
@thatrubylove

Advanced Ruby musings @ RubyLove.io
https://www.rubylove.io

Expert mentor @ Codementor.io
https://www.codementor.io/thatrubylove