Skip to content

Commit

Permalink
tried solving registration fail errors
Browse files Browse the repository at this point in the history
  • Loading branch information
JuliusCosmoRomeo committed Jan 24, 2017
1 parent a948486 commit b6362b0
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
26 changes: 23 additions & 3 deletions app/controllers/users/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,29 @@ class Users::RegistrationsController < Devise::RegistrationsController
# end

# POST /resource
# def create
# super
# end
def create
build_resource(sign_up_params)

resource.save
yield resource if block_given?
if resource.persisted?
if resource.active_for_authentication?
set_flash_message! :notice, :signed_up
sign_up(resource_name, resource)
respond_with resource, location: after_sign_up_path_for(resource)
else
set_flash_message! :notice, :"signed_up_but_#{resource.inactive_message}"
expire_data_after_sign_in!
respond_with resource, location: after_inactive_sign_up_path_for(resource)
end
else
clean_up_passwords resource
set_minimum_password_length
resource.errors.full_messages.each {|x| flash[x] = x} # Rails 4 simple way
respond_with resource
#respond_with_navigational(resource) { render_with_scope :new }
end
end

# GET /resource/edit
# def edit
Expand Down
3 changes: 2 additions & 1 deletion app/views/users/sessions/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
</div>
<div class="row spacer-30"></div>
<div class="panel panel-default devise-bs panel-body">
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), html: { role: "form" }) do |f| %>
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), html: { role: "form" }) do |f| %>
<!-- #registration_path(resource_name), html: { role: "form" }) do |f| -->
<div class="form-group">
<%= f.label :email %>
<%= f.email_field :email, autofocus: true, class: "form-control", id: "sign_up_email" %>
Expand Down
4 changes: 4 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
post 'download_material' => 'events#download_material', as: :download_material
end
resources :profiles, except: [:index, :destroy]

devise_scope :user do
get "/users/sign_up" => redirect("/users/sign_in")
end
devise_for :users, :controllers => {:registrations => "users/registrations"}
resources :users, only: [:index] # index page for devise users
patch 'users/:id/role' => 'users#update_role', as: :update_user_role
Expand Down

0 comments on commit b6362b0

Please sign in to comment.