diff --git a/app/controllers/macs_controller.rb b/app/controllers/macs_controller.rb index 14188e0..46d4aff 100644 --- a/app/controllers/macs_controller.rb +++ b/app/controllers/macs_controller.rb @@ -5,7 +5,10 @@ require "optparse" #require "rubygems" def index - @macs = Mac.all + @active_macs = Mac.where(:active => true, :hidden => false) + @active_macs += Mac.where(:active => true, :hidden => nil) + @hidden_macs = Mac.where(:active => true, :hidden => true) + @inactive_macs = Mac.where(:active => false) end # GET /macs/1 diff --git a/app/models/mac.rb b/app/models/mac.rb index 12f1a90..817c50a 100644 --- a/app/models/mac.rb +++ b/app/models/mac.rb @@ -1,4 +1,4 @@ class Mac < ActiveRecord::Base belongs_to :user - attr_accessible :active, :ip, :mac, :refreshed, :since, :user_id + attr_accessible :active, :ip, :mac, :refreshed, :since, :hidden, :note, :user_id end diff --git a/app/views/macs/_form.html.erb b/app/views/macs/_form.html.erb index 9759232..a45e6e4 100644 --- a/app/views/macs/_form.html.erb +++ b/app/views/macs/_form.html.erb @@ -13,12 +13,20 @@
<%= f.label :user_id, "User" %>
- <%= collection_select(:mac, :user_id, @users, :id, :name) %> + <%= collection_select(:mac, :user_id, @users, :id, :name, :include_blank => true) %>
- <%= f.label :mac, "Mac" %>
+ <%= f.label :mac %>
<%= f.text_field :mac %>
+
+ <%= f.label :note %>
+ <%= f.text_field :note %> +
+
+ <%= f.label :hidden %>
+ <%= f.check_box :hidden %> +
<%= f.submit %>
diff --git a/app/views/macs/index.html.erb b/app/views/macs/index.html.erb index bac5e36..6148684 100644 --- a/app/views/macs/index.html.erb +++ b/app/views/macs/index.html.erb @@ -1,5 +1,5 @@

What machines are on our network?

-<% @macs.each do |mac| %> +<% @active_macs.each do |mac| %> <%= mac.user.name unless mac.user.blank? %> <%= mac.mac if mac.user.blank? %> | <%= link_to 'Edit', edit_mac_path(mac) %>
<% end %> +
+<% @hidden_macs.each do |mac| %> + <%= mac.user.name unless mac.user.blank? %> + <%= mac.mac if mac.user.blank? %> + (<%= mac.note %>) | + <%= link_to 'Edit', edit_mac_path(mac) %>
+<% end %> +
+<% @inactive_macs.each do |mac| %> + <%= mac.user.name unless mac.user.blank? %> + <%= mac.mac if mac.user.blank? %> + (<%= mac.note %>) | + <%= link_to 'Edit', edit_mac_path(mac) %>
+<% end %> diff --git a/app/views/macs/show.html.erb b/app/views/macs/show.html.erb index 340d91c..d8f503f 100644 --- a/app/views/macs/show.html.erb +++ b/app/views/macs/show.html.erb @@ -8,5 +8,20 @@ <%= @mac.mac %>

+

+ Note: + <%= @mac.note %> +

+ +

+ Hidden: + <%= @mac.hidden %> +

+ +

+ IP: + <%= @mac.ip %> +

+ <%= link_to 'Edit', edit_mac_path(@mac) %> | <%= link_to 'Back', macs_path %> diff --git a/db/migrate/20130201042646_add_properties_to_macs.rb b/db/migrate/20130201042646_add_properties_to_macs.rb new file mode 100644 index 0000000..f75672a --- /dev/null +++ b/db/migrate/20130201042646_add_properties_to_macs.rb @@ -0,0 +1,6 @@ +class AddPropertiesToMacs < ActiveRecord::Migration + def change + add_column :macs, :hidden, :boolean + add_column :macs, :note, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 148d575..d957967 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20130201022153) do +ActiveRecord::Schema.define(:version => 20130201042646) do create_table "cards", :force => true do |t| t.string "card_number" @@ -52,6 +52,8 @@ ActiveRecord::Schema.define(:version => 20130201022153) do t.boolean "active" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false + t.boolean "hidden" + t.string "note" end add_index "macs", ["user_id"], :name => "index_macs_on_user_id"