Created
August 4, 2012 15:52
-
-
Save psychocandy/3258481 to your computer and use it in GitHub Desktop.
Module einbinden (Frage auf XING https://www.xing.com/app/forum?op=showarticles;seoparsed=1;id=41621260;sc_o=as_g)
This file contains 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 characters
# lib/stop_words.rb: | |
module StopWords | |
def stop_words_finder | |
stop_words = ["ich", "heute"] | |
end | |
end | |
# models/pool.rb: | |
class Pool < ActiveRecord::Base | |
attr_accessible :pooltext | |
include StopWords | |
end | |
# controllers/application_controller.rb: | |
class ApplicationController < ActionController::Base | |
def foo | |
pool = Pool.new | |
stop_words = pool.stop_words_finder | |
data = %q{Ich gehe heute schwimmen. Und du?} | |
key_words = data.split.select { |word| !stop_words.include?(word) } | |
pool.pooltext = key_words.join(' ') | |
pool.save! | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment