diff --git a/.gitignore b/.gitignore index 1aa65a5..705de5c 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,6 @@ # Ignore compiled assets /public/assets + +# Ignore config file +/config/config.yml diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 5f6e135..fdfdb03 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -69,7 +69,7 @@ class UsersController < ApplicationController respond_to do |format| if @user.save - format.html { redirect_to @user, :notice => 'User was successfully created.' } + format.html { redirect_to users_url, :notice => 'User was successfully created.' } format.json { render :json => @user, :status => :created, :location => @user } else format.html { render :action => "new" } @@ -85,7 +85,7 @@ class UsersController < ApplicationController respond_to do |format| if @user.update_attributes(params[:user]) - format.html { redirect_to @user, :notice => 'User was successfully updated.' } + format.html { redirect_to users_url, :notice => 'User was successfully updated.' } format.json { head :no_content } else format.html { render :action => "edit" } @@ -101,7 +101,7 @@ class UsersController < ApplicationController @user.destroy respond_to do |format| - format.html { redirect_to users_url } + format.html { redirect_to users_url, :notice => 'User successfully deleted.' } format.json { head :no_content } end end diff --git a/app/models/door_log.rb b/app/models/door_log.rb index 646e5b5..267a893 100644 --- a/app/models/door_log.rb +++ b/app/models/door_log.rb @@ -3,14 +3,18 @@ class DoorLog < ActiveRecord::Base require 'open-uri' def self.download_from_door - # do shit here - source = open("http://192.168.1.177?e=1234").read + # load config values + door_access_url = APP_CONFIG['door_access_url'] + door_access_password = APP_CONFIG['door_access_password'] + + # connect to door access system + source = open("#{door_access_url}?e=#{door_access_password}").read results = source.scan(/authok/) if(results.size > 0) then @end_results = Array.new #only continue if we've got an OK login - source = open("http://192.168.1.177?z").read + source = open("#{door_access_url}?z").read results = source.scan(/(.*): (.*)\r\n/) results.each do |r| @@ -20,9 +24,9 @@ class DoorLog < ActiveRecord::Base end #clear log - open("http://192.168.1.177?y") + open("#{door_access_url}?y") #logout - open("http://192.168.1.177?e=0000") + open("#{door_access_url}?e=0000") if(results.size > 0) then #only return true if we got some kind of decent response diff --git a/app/models/user.rb b/app/models/user.rb index b44fbb7..6277ac3 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -2,7 +2,7 @@ class User < ActiveRecord::Base # Include default devise modules. Others available are: # :token_authenticatable, :confirmable, # :lockable, :timeoutable and :omniauthable - devise :database_authenticatable, :registerable, + devise :database_authenticatable, # :registerable, :recoverable, :rememberable, :trackable, :validatable # Setup accessible (or protected) attributes for your model diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index b226d38..cb3d6eb 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -10,10 +10,8 @@
<%= notice %>
<%= alert %>
diff --git a/app/views/users/_form.html.erb b/app/views/users/_form.html.erb index 8cd4743..5af47f9 100644 --- a/app/views/users/_form.html.erb +++ b/app/views/users/_form.html.erb @@ -15,6 +15,20 @@ <%= f.label :name %>