Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to devise and allow user invitations
- Loading branch information
1 parent
7592ef9
commit f4b1b84
Showing
36 changed files
with
712 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,45 @@ | ||
You look great in Suspenders | ||
Campmaster | ||
============================ | ||
Project setup | ||
------------- | ||
|
||
Use the following guides for getting things done, programming well, and | ||
programming in style. | ||
Get the code. | ||
|
||
* [Protocol](http://github.com/thoughtbot/guides/blob/master/protocol) | ||
* [Best Practices](http://github.com/thoughtbot/guides/blob/master/best-practices) | ||
* [Style](http://github.com/thoughtbot/guides/blob/master/style) | ||
git clone git@github.com:drapergeek/wuzup.git | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
Set up the project's dependencies. | ||
|
||
cd project | ||
rake dev:setup | ||
|
||
This will automatically add a heroku remote for staging and production. | ||
|
||
Running tests: | ||
|
||
rake | ||
|
||
|
||
Use [Foreman](http://goo.gl/oy4uw) to run the app locally. | ||
|
||
foreman start | ||
|
||
It uses your `.env` file and `Procfile` to run processes just like Heroku's | ||
[Cedar](https://devcenter.heroku.com/articles/cedar/) stack. | ||
|
||
Anytime any development data is needed, add it to the dev:prime tasks. At any | ||
point you can reset your local development data with: | ||
|
||
rake dev:prime | ||
|
||
|
||
Deploy | ||
------ | ||
After code is commited to the master branch, it is automatically deployed to | ||
heroku if all the tests pass. You can also manually deploy: | ||
|
||
git push staging | ||
|
||
Run migrations (if necessary). | ||
|
||
heroku run rake db:migrate --app campmaster-staging | ||
heroku restart --app campmaster-staging |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
class ApplicationController < ActionController::Base | ||
include Clearance::Authentication | ||
protect_from_forgery | ||
before_filter :authenticate_user! | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
class Users::InvitationsController < Devise::InvitationsController | ||
|
||
private | ||
def resource_params | ||
if params[:user] | ||
if action_name == 'update' | ||
update_params | ||
else | ||
create_params | ||
end | ||
end | ||
end | ||
|
||
def create_params | ||
params.require(:user).permit(:email, :name, :role) | ||
end | ||
|
||
def update_params | ||
params.require(:user).permit(:name, :password, :password_confirmation, :invitation_token) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class UsersController < ApplicationController | ||
def index | ||
@users = User.all | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
class User < ActiveRecord::Base | ||
include Clearance::User | ||
attr_accessible :email, :password | ||
include ActiveModel::ForbiddenAttributesProtection | ||
devise :invitable, :database_authenticatable, :recoverable, :rememberable | ||
|
||
validates :name, presence: true | ||
validates :role, presence: true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<h2><%= t 'devise.invitations.edit.header' %></h2> | ||
|
||
<%= simple_form_for resource, :as => resource_name, :url => invitation_path(resource_name), :html => { :method => :put } do |f| %> | ||
<%= devise_error_messages! %> | ||
<%= f.hidden_field :invitation_token %> | ||
<%= f.input :name %> | ||
<%= f.input :password %> | ||
<%= f.input :password_confirmation %> | ||
<%= f.submit t("devise.invitations.edit.submit_button") %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<h2><%= t "devise.invitations.new.header" %></h2> | ||
|
||
<%= simple_form_for resource, :as => resource_name, :url => invitation_path(resource_name), :html => {:method => :post} do |f| %> | ||
<%= devise_error_messages! %> | ||
<%= f.input :name %> | ||
<%= f.input :email %> | ||
<%= f.input :role %> | ||
<%= f.submit t("devise.invitations.new.submit_button") %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<p>Hello <%= @resource.email %>!</p> | ||
|
||
<p>Someone has invited you to <%= root_url %>, you can accept it through the link below.</p> | ||
|
||
<p><%= link_to 'Accept invitation', accept_invitation_url(@resource, :invitation_token => @resource.invitation_token) %></p> | ||
|
||
<p>If you don't want to accept the invitation, please ignore this email.<br /> | ||
Your account won't be created until you access the link above and set your password.</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This is the home page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<table class="table table-striped"> | ||
<tr> | ||
<th>Email</th> | ||
<th>Role</th> | ||
</tr> | ||
<% @users.each do |user| %> | ||
<tr> | ||
<td><%= user.email %></td> | ||
<td><%= user.role %></td> | ||
</tr> | ||
<% end %> | ||
</table> | ||
<%= link_to "Invite New User", new_user_invitation_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
This is not correct