This is the Rails API for the Facebook Political Ad Collector. For a full breakdown of the other services you'll need to deploy the app, see the README for our main repo.
First, this will mirror most of the admin-facing functions of the Rust API, then adding new stuff more nimbly to respond to what we want to present to partners and readers.
It's structured to be a drop-in replacement for some pieces of the Rust API… and to run alongside it. (The Rust API will continue to catch the ads and to serve static assets.)
- You should have the Rust app installed and running.
- Clone this repo.
bundle install
in the root of this repo (if you don't have bundler installed, rungem install bundle
first).- Run
rake db:migrate
just to be sure we have all the changes we need. (Unless you have a post-4/4/2018 DB dump). If you don't have a past database dump, you'll want to runrake db:create && rake db:migrate
instead. bundle exec rails s
- Visit http://localhost:3000/fbpac-api/ads -- you should see a big pile of JSON.
- Visit http://localhost:3000/fbpac-api/ads/by_advertisers -- you should see a log in page.
- Create a user for yourself, locally, by running this in
rails c
.Partner.create!({:email => "you@example.com", :password => "111111", :password_confirmation => "111111" })
. - Try http://localhost:3000/fbpac-api/ads/by_advertisers again, log in, then you should see more JSON.
rake test
runs the tests. Be sure to write new ones for new features!
Unlike the Rust API, we have real user accounts with a unique password per account. When a partner signs up, log into the production console with RAILS_ENV=production rails c
and create them a user account with Partner.create!({:email => "you@example.com", :password => "111111", :password_confirmation => "111111" })
(there is no GUI for account creation). Then they should be good to go.