Skip to content

Commit

Permalink
#190 #162 WIP enabling user registrations. New User account page loads.
Browse files Browse the repository at this point in the history
  • Loading branch information
rsmithlal committed Apr 20, 2019
1 parent af8798a commit f91c0aa
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
10 changes: 10 additions & 0 deletions app/controllers/users/registrations_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

module Users
class RegistrationsController < Devise::RegistrationsController
def new
@form = NewUserForm.new(User.new)
authorize @form.model
super
end
end
end
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class User < ApplicationRecord

# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :invitable, :database_authenticatable, # # Commenting registerable to make it invite only.
devise :invitable, :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable, :confirmable

acts_as_messageable
Expand Down
4 changes: 4 additions & 0 deletions app/policies/user_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@ def update?
def destroy?
user.id == record.id || super
end

def create?
true
end
end
2 changes: 1 addition & 1 deletion app/views/devise/registrations/new.html.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.col-sm-6.col-sm-offset-3
%h2= t('auth.sign_up_header')
= simple_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f|
= simple_form_for(@form, as: resource_name, url: registration_path(resource_name)) do |f|
= f.error_notification
.form-inputs
= f.input :email, required: true, autofocus: true
Expand Down
5 changes: 4 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@

resources :community_offers, only: [:new, :create]

devise_for :users, controllers: { invitations: 'users/invitations' }
devise_for :users, controllers: {
invitations: 'users/invitations',
registrations: 'users/registrations'
}
resources :users, only: [:edit, :update, :destroy]

get 'pods/home', controller: :pods, action: :home, as: :home_pod
Expand Down

0 comments on commit f91c0aa

Please sign in to comment.