Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix background persistence

  • Loading branch information...
commit f9a131043682d1c67f3c825e07a71fea50692524 1 parent 87f9619
@rwdaigle authored
View
2  .gitignore
@@ -1,3 +1,3 @@
.env
log
-db/sql*.sql
+db/*.sql*
View
4 Rakefile
@@ -35,7 +35,9 @@ namespace :resque do
task :setup => "queue:environment" do
Resque.after_fork do |job|
- ActiveRecord::Base.establish_connection if job.is_a?(PersistTweet)
+ if job.payload_class == PersistTweet
+ require File.dirname(__FILE__) + "/config/active_record"
+ end
end
end
end
View
BIN  db/development.sqlite3
Binary file not shown
View
2  jobs/persist_tweet.rb
@@ -7,7 +7,7 @@ class PersistTweet
def self.perform(tweet)
puts "Saving tweet: #{tweet["text"]}"
- Tweet.create!(:user => tweet["username"], :text => tweet["text"])
+ Tweet.create!(:user => tweet["user"]["screen_name"], :text => tweet["text"])
end
end
View
2  models/tweet.rb
@@ -4,6 +4,6 @@
class Tweet < ActiveRecord::Base
after_create { |tweet|
puts "Indexing #{tweet["text"]}"
- $index.document(tweet.to_param).add(tweet)
+ $index.document(tweet.to_param).add(:text => tweet.text, :user => tweet.user)
}
end
Please sign in to comment.
Something went wrong with that request. Please try again.