session - Rails - Limit action per ip adress for post -


hi new rails , working on application option posts,i try limit action of 1 per post , can't figure out how,the app doesn't include users can post think best way ip or sessions , can please give me guide line?

my action

  def    @post = post.find(params[:id])    @post.likes += 1    @post.save    redirect_to root_path   end 

you make post.likes attribute array of ips instead of integer, check array existence of requester's ip determine whether or not they've "liked" post.

for more scalable solution, you'll need mechanism tying "like" action particular user. want like model belongs_to user , post accomplish this.


Comments