0

I have built a rails application. I have installed Devise for Users registraion and added the before_action :authenticate_user! Method, However what this method does is redirect the user who didn't sign up to the login page. What i want is to redirect them to the sign up page instead of the login page.

Here's my code:

rails_course_controller.rb

class RailsCourseController < ApplicationController
  before_action :authenticate_user!


  def railsDashboard
  end

  def getting_started
  end

  def whatisurbyandrails
  end

  def downloadRails
  end

  def windows_download
end

end
Daniel Waghorn
  • 2,997
  • 2
  • 20
  • 33
AHmed
  • 351
  • 1
  • 6
  • 20
  • 1
    Possible duplicate of [Redirect to log in page if user is not authenticated with Devise](http://stackoverflow.com/questions/23555618/redirect-to-log-in-page-if-user-is-not-authenticated-with-devise) – Linus Oleander Feb 15 '16 at 00:08
  • 1
    Also; Ruby is using `snail_casing`, not `camelCasing`. – Linus Oleander Feb 15 '16 at 00:08

2 Answers2

3

You can override the default behavior of the :authenticate_user! method. In your application_controller.rb add this:

protected
def authenticate_user!
  if user_signed_in?
    super
  else
    redirect_to sign_up_path, :notice => 'Please sign up first'
  end
end
Fabiano Arruda
  • 648
  • 7
  • 21
0

Might be you can find the answer here:

http://[stackoverflow.com/questions/18903145/how-to-make-sign-up-page-be-root-page-in-devise?rq=1][1]

kajal ojha
  • 1,248
  • 8
  • 20