Commit 1fa52ab55625c7105cd96e96bb66f05664fd2223

Authored by Pius Uzamere
1 parent 8f135d16

quick link to geocoded ip

app/models/click.rb
1 class Click < ActiveRecord::Base 1 class Click < ActiveRecord::Base
2 belongs_to :site 2 belongs_to :site
3 belongs_to :visitor 3 belongs_to :visitor
  4 +
  5 + def page
  6 + ip = what_was_clicked.split('[ip: ')[1].split(']').first rescue nil
  7 + end
  8 +
  9 +
  10 + def ip
  11 + ip = what_was_clicked.split('[ip: ')[1].split(']').first rescue nil
  12 + end
  13 +
  14 + def to_html
  15 + if ip
  16 + return what_was_clicked.gsub('ip', "http://api.hostip.info/get_html.php?ip=#{ip}")
  17 + else
  18 + return what_was_clicked
  19 + end
  20 + end
4 end 21 end
app/views/clicks/index.html.erb
@@ -13,7 +13,7 @@ @@ -13,7 +13,7 @@
13 <tr> 13 <tr>
14 <td><%=h click.site_id %></td> 14 <td><%=h click.site_id %></td>
15 <td><%=h click.visitor_id %></td> 15 <td><%=h click.visitor_id %></td>
16 - <td><%=h click.what_was_clicked %></td> 16 + <td><%=h click.to_html %></td>
17 <td><%= link_to 'Show', click %></td> 17 <td><%= link_to 'Show', click %></td>
18 <td><%= link_to 'Destroy', click, :confirm => 'Are you sure?', :method => :delete %></td> 18 <td><%= link_to 'Destroy', click, :confirm => 'Are you sure?', :method => :delete %></td>
19 </tr> 19 </tr>
app/views/layouts/clicks.html.erb
@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 3
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5 <head> 5 <head>
  6 + <script src="http://www.google.com/jsapi"></script>
6 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> 7 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
7 <script type="text/javascript" src="/javascripts/highcharts.js"></script> 8 <script type="text/javascript" src="/javascripts/highcharts.js"></script>
8 <!--[if IE]> 9 <!--[if IE]>