Skip to content
This repository has been archived by the owner on Mar 1, 2018. It is now read-only.

Commit

Permalink
Adding last_ip to Computer model, and updating on successful checkin
Browse files Browse the repository at this point in the history
  • Loading branch information
Ricky Chilcott committed May 22, 2014
1 parent 521d384 commit fd9c9c2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/controllers/computers_controller.rb
Expand Up @@ -159,6 +159,7 @@ def checkin
@computer.system_profile.attributes = system_profile_hash
end

@computer.last_ip = request.remote_ip
@computer.save

if @computer.warranty.present? and @computer.serial_number != @computer.warranty.serial_number
Expand Down
4 changes: 2 additions & 2 deletions app/views/computers/_computer_table.html.erb
Expand Up @@ -35,8 +35,8 @@
<% end %>

<td><%= image_tag c.icon.url(:small), :class => "thumbnail" if c.icon %></td>
<td><%= link_to c.name, computer_path(c.unit, c) %></td>
<td><%= link_to c.hostname, computer_path(c.unit, c) %></td>
<td><%= link_to c.name, computer_path(c.unit, c), title: "Last IP: #{c.last_ip}" %></td>
<td><%= link_to c.hostname, computer_path(c.unit, c) %></td>
<td><%= c.mac_address %></td>
<td><%= c.last_report_at_time %></td>
<td>
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20140522195742_add_last_ip_to_computer.rb
@@ -0,0 +1,5 @@
class AddLastIpToComputer < ActiveRecord::Migration
def change
add_column :computers, :last_ip, :string, default: ""
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20130418013709) do
ActiveRecord::Schema.define(:version => 20140522195742) do

create_table "bundle_items", :force => true do |t|
t.integer "manifest_id"
Expand Down Expand Up @@ -80,6 +80,7 @@
t.integer "configuration_id"
t.string "shortname"
t.datetime "last_report_at"
t.string "last_ip", :default => ""
end

create_table "configurations", :force => true do |t|
Expand Down

0 comments on commit fd9c9c2

Please sign in to comment.