Merge branch 'master' of github.com:ZeusWPI/Tab

This commit is contained in:
Ilion Beyst 2015-09-09 11:32:40 +02:00
commit d32bfc55fb
5 changed files with 26 additions and 3 deletions

View file

@ -82,3 +82,5 @@ group :production do
end end
gem 'high_voltage', '~> 2.4.0' gem 'high_voltage', '~> 2.4.0'
gem 'simple_form'

View file

@ -217,6 +217,9 @@ GEM
select2-rails (3.5.9.3) select2-rails (3.5.9.3)
thor (~> 0.14) thor (~> 0.14)
sexp_processor (4.6.0) sexp_processor (4.6.0)
simple_form (3.1.1)
actionpack (~> 4.0)
activemodel (~> 4.0)
spring (1.3.6) spring (1.3.6)
sprockets (3.3.4) sprockets (3.3.4)
rack (~> 1.0) rack (~> 1.0)
@ -276,6 +279,7 @@ DEPENDENCIES
sass-rails (~> 5.0) sass-rails (~> 5.0)
sdoc (~> 0.4.0) sdoc (~> 0.4.0)
select2-rails select2-rails
simple_form
spring spring
sqlite3 sqlite3
turbolinks turbolinks

View file

@ -11,10 +11,19 @@ class ApplicationController < ActionController::Base
@current_client ||= identify_client @current_client ||= identify_client
end end
def current_ability
if current_user
@current_ability ||= Ability.new(current_user)
elsif current_client
@current_ability ||= ClientAbility.new(current_account)
end
end
private private
def identify_client def identify_client
key = request.headers["X-API-KEY"] key = request.headers["X-API-KEY"]
Client.find_by key: key if key Client.find_by key: key if key
end end
end end

View file

@ -0,0 +1,8 @@
class Ability
include CanCan::Ability
def initialize(client)
client ||= Client.new # guest user (not logged in)
can :manage, :all
end
end

View file

@ -1,6 +1,6 @@
= @transaction.errors.full_messages.join(", ") = @transaction.errors.full_messages.join(", ")
= form_for @transaction do |f| = simple_form_for @transaction do |f|
= f.collection_select :creditor_id, User.all, :id, :name, {}, { class: 'select2-selector' } = f.collection_select :creditor_id, User.all, :id, :name, {}, { class: 'select2-selector' }
= f.number_field :amount = f.input :amount
= f.text_field :message, required: true = f.input :message, required: true
= f.submit "Send it!" = f.submit "Send it!"