diff --git a/app/models/click.rb b/app/models/click.rb index 0722777..6bd4570 100644 --- a/app/models/click.rb +++ b/app/models/click.rb @@ -1,4 +1,21 @@ class Click < ActiveRecord::Base belongs_to :site belongs_to :visitor + + def page + ip = what_was_clicked.split('[ip: ')[1].split(']').first rescue nil + end + + + def ip + ip = what_was_clicked.split('[ip: ')[1].split(']').first rescue nil + end + + def to_html + if ip + return what_was_clicked.gsub('ip', "http://api.hostip.info/get_html.php?ip=#{ip}") + else + return what_was_clicked + end + end end diff --git a/app/views/clicks/index.html.erb b/app/views/clicks/index.html.erb index bd607b9..84f104b 100644 --- a/app/views/clicks/index.html.erb +++ b/app/views/clicks/index.html.erb @@ -13,7 +13,7 @@