Reputation: 921
I am using the rmeetup gem to grab information from the meetup group. When I try to pull information from the results, all works except time and I receive a 'can't convert Fixnum into String'
My code:
<% RMeetup::Client.api_key = "APICODE"
results = RMeetup::Client.fetch(:open_events, { topic: "business", city: "syracuse", state: "ny"}) %>
<%= results.count %><br/>
<%= results.each do |result| %>
<%= result.name %>
<%= result.id %>
<%= result.waitlist_count %>
<%= result.utc_offset %>
<%= result.created %>
<%= result.time.to_s %>
<hr/
<% end %>
What is strange is that the .id, .waitlist_count, .utf_offset, .created all work and all are numbers, but .time wont work and will not allow to me convert to string.
Upvotes: 0
Views: 1854
Reputation: 17169
Almost every object, going all the way up to Object
, contains a to_s
method on it.
Object.new.to_s #=> "#<Object:0x1668fa8>"
This means that your problem isn't in the to_s
method that is getting called by <%= ... %>
.
Looking at the event.rb
file in the rmeetup gem, you'll notice:
self.time = DateTime.parse(event['time'])
This means that the instance variable you are calling with result.time
is of the type DateTime
. Also note that it is getting set by using DateTime.parse
which takes a string. So what happens when you pass a Fixnum to DateTime.parse
?
DateTime.parse(42) #=> 'no implicit conversation of Fixnum into String'
According to the MeetUp API, the time
is returned as:
UTC start time of the event, in milliseconds since the epoch
The original RMeetup gem was last updated 5 years ago. Are you using a more recent fork? If not, it could be that the gem has simply broken as new APIs are released by MeetUp. I would suggest either finding a more up-to-date gem for accessing the MeetUp API or fork the gem and make your own alterations.
Upvotes: 1