What are we known for:
We wanted to do a GET request
to get all of the upcoming meetups and
dynamically display them on the site.
How did we do this?
1. We generated an api key from the meetup website:
https://secure.meetup.com/meetup_api/key/
2. Once we had access, we researched the JSON
results and tried to make sense of the data:
JSON RESULTS
3. After getting a handle on the Meetup API, we started
to align the design with technical needs.
Which attributes did we need to save for the database?
rails g model UpcomingMeetup meetup_name:string time:datetime ...
Once the schema was generated, we were ready
to start coding with helper tests, which described what
the scraper method would return.
module UpdaterHelper def get_json (source = 'https://api.meetup.com/events&sign=true&photo
host=public&group_urlname=laruby&sign=true&key=6667405f41112c7f127c4f243e7243b')
...
end
def search_meetup_ids(data)
... end def save_meetup_ids(hash) ... end
end
We had to scrape organizer names and assign them to
groups in order to associate the meetup with a group.
We wanted to make the json data from the meetup api
match our database as closely as possible;
while still making sense of it for
our application.
UpcomingMeetups Controller
if params[:id].to_s.length > 8
UpcomingMeetup.select(:id, :group_id).upcoming.distinct.each do |meetup|
if meetup.group.name == params[:id]
@meetup = UpcomingMeetup.where(:id => meetup.id).first
@is_found = true
end
end
if @is_found.nil?
redirect_to ""
end
else
@meetup = UpcomingMeetup.where(:id => params[:id]).first
end
end
gem 'breadcrumbs_on_rails'
gem 'kaminari'
gem 'cloudinary'
gem 'carrierwave'
gem 'activeadmin', github: 'gregbell/active_admin'
gem 'geocoder'
gem 'devise', '~> 3.3.0'
gem 'rspec-rails', '~> 3.0.0'