diff --git a/app/controllers/macs_controller.rb b/app/controllers/macs_controller.rb index d26bc89..19fdea6 100644 --- a/app/controllers/macs_controller.rb +++ b/app/controllers/macs_controller.rb @@ -12,6 +12,8 @@ end load_and_authorize_resource :mac, :except => :create load_and_authorize_resource :user, :through => :mac, :except => [:index, :show, :scan, :import] +before_filter :arp_lookup, :only => :new + #require "active_record" require "optparse" #require "rubygems" @@ -136,7 +138,10 @@ end end end - +def arp_lookup + @ip = request.env['REMOTE_ADDR'] + @arp = %x(/usr/sbin/arp -a | grep #{@ip}) +end def scan Rails.logger.info "starting scan..." diff --git a/app/models/user.rb b/app/models/user.rb index 069582d..2604e15 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -15,6 +15,7 @@ class User < ActiveRecord::Base has_many :user_certifications has_many :certifications, :through => :user_certifications has_many :payments + has_many :macs validates_format_of [:twitter_url, :facebook_url, :github_url, :website_url], :with => URI::regexp(%w(http https)), :allow_blank => true diff --git a/app/views/macs/_form.html.erb b/app/views/macs/_form.html.erb index 61586dd..8287339 100644 --- a/app/views/macs/_form.html.erb +++ b/app/views/macs/_form.html.erb @@ -17,7 +17,8 @@
<% if current_user.admin? then %> Payments: