ruby on rails - Rake Task not inserting into database -
I have a ruby on the rail application where I need to run a rake function which will kill twitterstream api and one Enter tweets from a few places in a database For this, I prepared a table called uncat_tweets. My rake job looks like this
Tasks: get_uncat_tweets = & gt; : Environment Tweetstream.configure do | C | ... ... Finally "# {UncatTweets.count} Client =" ColorStream :: Client.Nue () Client Place (coordinate). Position | Puts "# {status.text}" in the form t = UncatTweets.new (") T.text = status.text t.long = ... t.lat = ... t.time = .... t. My uncat_tweets model looks like this: Class UncatTweets & lt; ActiveRecord :: Base attr_accessible: lat ,: long, .save! End : Text: time, user end
When I run rack get_uncat_tweets works tweetstream and spews out tweets. But rake does not push the database to work. The line puts " # {UncatTweets.count} ". I went to the Rail Console and tried to include the Dummy Value of UncatTweets And it worked! But when I work the rake work without any errors, but never goes to the database, what's going on here? I can not find a solution to this problem Please help me
Let's assume that this rail is 3, you should follow Rail 3 method to do this.
First of all, open db / seeds.rb in your Rail app, set it up (up your rack car Depending on the case): TweetStream.configure do | C | ... ... at the end "Number of Tweets: # {UncatTweets.count}" Client = TweetStream :: Client.new () # Note You must define the following variables "somewhere" to the coordinates of the client. Place (coordinate). Position | UncatTweets.create (: text = & gt; status.text ,: long = & gt; ...,: lat = & gt; ...,: time = & gt; ...) end < / Pre> and then run it by using rake db: seed
Comments
Post a Comment