devise-basecamper 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -108,6 +108,39 @@ If your application follows the assumptions, you DO NOT need to define any of th
108
108
  You can configure multiple models accordingly just as you can in Devise. If you have a Devise model that does not need
109
109
  the additional features offered by Devise-Basecamper, simple do not include the module. Devise will work just as expected.
110
110
 
111
+ ### Add some helpers to your Application controller
112
+
113
+ You will need to add a helper method to your application controller, I would also recommend the validation for dealing with subdomains that do not belong
114
+ to an account.
115
+
116
+ **Helper Methods**
117
+ ```
118
+ class ApplicationController < ActionController::Base
119
+ protect_from_forgery
120
+ helper_method :subdomain, :current_account
121
+ before_filter :validate_subdomain, :authenticate_user!
122
+
123
+ private # ----------------------------------------------------
124
+
125
+ def current_acount
126
+ # The where clause is assuming you are using Mongoid, change appropriately
127
+ # for ActiveRecord or a different supported ORM.
128
+ @current_account ||= Association.where(subdomain: subdomain).first
129
+ end
130
+
131
+ def subdomain
132
+ request.subdomain
133
+ end
134
+
135
+ # This will redirect the user to your 404 page if the account can not be found
136
+ # based on the subdomain. You can change this to whatever best fits your
137
+ # application.
138
+ def validate_subdomain
139
+ redirect_to '/404.html' if current_account.nil?
140
+ end
141
+ end
142
+ ```
143
+
111
144
  ### ORM Compatability
112
145
 
113
146
  Devise-Basecamper has very minimal interaction with your data layer, however it uses the same `orm_adapter` gem as Devise
@@ -1,5 +1,5 @@
1
1
  module Devise
2
2
  module Basecamper
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise-basecamper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: