Devise Login Form on another page

2019-08-11 09:25发布

问题:

I wish to add a devise login form to my home page (model called home)

I have found this but stuck where to put certain bits and work!

http://pupeno.com/2010/08/29/show-a-devise-log-in-form-in-another-page/

<h2>Sign in</h2>

<% form_for resource_name, resource, :url => session_path(resource_name) do |f| -%>
  <p><%= f.label :email %></p>
  <p><%= f.text_field :email %></p>

  <p><%= f.label :password %></p>
  <p><%= f.password_field :password %></p>

  <% if devise_mapping.rememberable? -%>
    <p><%= f.check_box :remember_me %> <%= f.label :remember_me %></p>
  <% end -%>

  <p><%= f.submit "Sign in" %></p>
<% end -%>

<%= render :partial => "shared/devise_links" %>

and (no idea where to put)

module ContentHelper
  def resource_name
    :user
  end

  def resource
    @resource ||= User.new
  end

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

My devise is set up as 'members' so any help would be great :) Cheers