Skip to Content
Phoenix Web Development
book

Phoenix Web Development

by Brandon Richey
April 2018
Beginner to intermediate content levelBeginner to intermediate
406 pages
9h 33m
English
Packt Publishing
Content preview from Phoenix Web Development

Implementing voting restrictions

Right now, anybody on the internet can essentially stuff the ballot with as many votes as our poor system will allow them to! This doesn't make for very fair polls, so we'll take a naive approach and implement an IP-based list of people who have already voted on each particular poll!

We'll need to start off by figuring out a way to identify the user's IP address. The good news is that Phoenix already has that information ready for us in the conn object! In the conn object, one of the keys in the map is remote_ip, which is a tuple of the four octets in the IP address of the connecting user! We can verify this either by placing an IEx.pry statement in one of our controller actions and taking a look at the output ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Phoenix in Action

Phoenix in Action

Geoffrey Lessel
Real-Time Phoenix

Real-Time Phoenix

Stephen Bussey

Publisher Resources

ISBN: 9781787284197Supplemental Content