1

I'm using Feedzirra to parse feed, and the method for creating entries is like

class Feed < ActiveRecord::Base

def create_entries rawfeed
   self.entries.create(title: rawfeed.title, content:rawfeed.content, published:rawfeed.published, 
                 url: rawfeed.url, guid: rawfeed.id)
end

It works fine except the created entry's "published" time is really wired: something like

2000-01-01 17:26:15 UTC 

I check the entry I passed to the create method, it looks fine. So I just have no idea what goes wrong. Other attributes are all normal, including the "created_at" attribute. Anyone has suggestion? Thanks very much.

melodrama
  • 265
  • 1
  • 5
  • 14

1 Answers1

1

I met the same problem with mysql.

Your Entry's 'published' field is defined as :time? Look migration file for Entry, such as db/migrate/XXXXX_create_entries.rb

After changing :time to :datetime, everything goes fine.

Please try this solution.

P.S.

In development env, the problem does not happen. I think SQLite differ in the way to handle the field :time from the way of MySQL.

xoyip
  • 82
  • 6
  • I've mistaken... Whatever DB you used, :time field can handle only 'TIME', without year s, months and days. I made sure with SQLite3 and MySQL. – xoyip May 10 '13 at 13:50
  • Thanks for your solution. It really works. I didn't notice ":datetime". – melodrama May 11 '13 at 17:59