-1

Rather than using the Devise views created through

rails g devise:views

Is it possible to use devise with existing sign up/in pages?

I know you can create the devise controllers and views but what is the process for creating your own?

I have read something about overriding controllers so it seems possible?

Dunny
  • 77
  • 9

1 Answers1

1

so you want to login not from default devise views right?

put this in your controller

helper_method :resource_name, :resource, :devise_mapping

  def resource_name
    :user
  end

  def resource
    @resource ||= User.new
  end

  def devise_mapping
    @devise_mapping ||= Devise.mappings[:user]
  end

and make sure ur login form is like this

<%= form_for(:user, :url => session_path(:user)) do |f| %>
  <%= f.text_field :email %>
  <%= f.password_field :password %>
  <%= f.check_box :remember_me %>
  <%= f.label :remember_me %>
  <%= f.submit 'Sign in' %>
  <%= link_to "Forgot your password?", new_password_path(:user) %>
<% end %>
buncis
  • 2,148
  • 1
  • 23
  • 25
  • This looks like exactly what I need. In order to make my own signin , forgotten password etc pages is the approach the same? – Dunny Jun 09 '17 at 16:10
  • pretty much same, more is here https://github.com/plataformatec/devise/wiki/How-To:-Display-a-custom-sign_in-form-anywhere-in-your-app and https://stackoverflow.com/questions/9381817/devise-sign-up-form-on-the-home-page-as-well – buncis Jun 09 '17 at 16:11