devise-basecamper 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +33 -0
- data/lib/devise-basecamper/version.rb +1 -1
- metadata +1 -1
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
|