Comments (4)
And, if you define a transformer for dates everything breaks when reading a date string over HTTP with:
NoMethodError: undefined method `gsub!' for #<Date: 2011-12-31 (4911853/2,0,2299161)>
This when defining the class with a date property like:
property :date, :transformer => lambda {|date| Date.parse(date)}
This works as expected, it parses the date to a Date object:
Post.new(:date => "2010-01-01")
You can work around this if you define your transformer as:
lambda {|date| Date.parse(date) unless date.is_a? Date}
from api_smith.
I experienced something related to this issue. We implemented our date transformers with the assumption that strings will be automatically transformed into date objects first. But then after an update of the httparty gem version to 0.8.0, the date strings we're not being transformed automatically anymore. So if you want the strings to not be transformed automatically, maybe try locking your httparty version to 0.8.0, if not, then use 0.7.8. Hope this may be helpful to someone.
from api_smith.
Thanks fcbajao, i actually implemented the API-consumer in an async fashion with EventMachine's HttpRequest gem instead. But thanks for the info, it will be useful in the future!
from api_smith.
hey guys i am having the same problem and i'm stuck, can't figure it out. can you please help me. is there a way to format the date so that it gets parsed the right way?
here is the error i'm getting
undefined method `gsub!' for Thu, 05 Jan 2012:Date
from api_smith.
Related Issues (5)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from api_smith.