mirror of
https://github.com/heartcombo/devise.git
synced 2026-02-17 10:01:49 -05:00
Adding devise_views generator
This commit is contained in:
@@ -1 +1,5 @@
|
|||||||
script/generate devise User
|
To create a devise resource user:
|
||||||
|
|
||||||
|
script/generate devise User
|
||||||
|
|
||||||
|
This will generate a model named User, a route map for devise called :users, and a migration file for table :users with all devise modules.
|
||||||
|
|||||||
3
generators/devise_views/USAGE
Normal file
3
generators/devise_views/USAGE
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
To copy all session, password and confirmation views from devise to your app just run the following command:
|
||||||
|
|
||||||
|
script/generate devise_views
|
||||||
24
generators/devise_views/devise_views_generator.rb
Normal file
24
generators/devise_views/devise_views_generator.rb
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
class DeviseViewsGenerator < Rails::Generator::Base
|
||||||
|
|
||||||
|
def manifest
|
||||||
|
record do |m|
|
||||||
|
views_directory = File.join('app', 'views')
|
||||||
|
m.directory views_directory
|
||||||
|
|
||||||
|
{
|
||||||
|
:sessions => [:new],
|
||||||
|
:passwords => [:new, :edit],
|
||||||
|
:confirmations => [:new],
|
||||||
|
:notifier => [:confirmation_instructions, :reset_password_instructions]
|
||||||
|
}.each do |dir, templates|
|
||||||
|
m.directory File.join(views_directory, dir.to_s)
|
||||||
|
|
||||||
|
templates.each do |template|
|
||||||
|
template_path = "#{dir}/#{template}.html.erb"
|
||||||
|
m.file "#{template_path}", "#{views_directory}/#{template_path}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
16
generators/devise_views/templates/confirmations/new.html.erb
Normal file
16
generators/devise_views/templates/confirmations/new.html.erb
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<h2>Resend confirmation instructions</h2>
|
||||||
|
|
||||||
|
<% form_for resource_name, :url => confirmation_path(resource_name) do |f| %>
|
||||||
|
<%= f.error_messages %>
|
||||||
|
|
||||||
|
<p><%= f.label :email %></p>
|
||||||
|
<p><%= f.text_field :email %></p>
|
||||||
|
|
||||||
|
<p><%= f.submit "Resend confirmation instructions" %></p>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<%= link_to "Sign in", new_session_path(resource_name) %><br />
|
||||||
|
|
||||||
|
<%- if devise_mapping.recoverable? %>
|
||||||
|
<%= link_to "Forgot password?", new_password_path(resource_name) %><br />
|
||||||
|
<% end -%>
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
Welcome <%= @resource.email %>!
|
||||||
|
|
||||||
|
You can confirm your account through the link below:
|
||||||
|
|
||||||
|
<%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %>
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
Hello <%= @resource.email %>!
|
||||||
|
|
||||||
|
Someone has requested a link to change your password, and you can do this through the link below.
|
||||||
|
|
||||||
|
<%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %>
|
||||||
|
|
||||||
|
If you didn't request this, please ignore this email.
|
||||||
|
Your password won't change until you access the link above and create a new one.
|
||||||
20
generators/devise_views/templates/passwords/edit.html.erb
Normal file
20
generators/devise_views/templates/passwords/edit.html.erb
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<h2>Change your password</h2>
|
||||||
|
|
||||||
|
<% form_for resource_name, :url => password_path(resource_name), :html => { :method => :put } do |f| %>
|
||||||
|
<%= f.error_messages %>
|
||||||
|
<%= f.hidden_field :reset_password_token %>
|
||||||
|
|
||||||
|
<p><%= f.label :password %></p>
|
||||||
|
<p><%= f.password_field :password %></p>
|
||||||
|
|
||||||
|
<p><%= f.label :password_confirmation %></p>
|
||||||
|
<p><%= f.password_field :password_confirmation %></p>
|
||||||
|
|
||||||
|
<p><%= f.submit "Change my password" %></p>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<%= link_to "Sign in", new_session_path(resource_name) %><br />
|
||||||
|
|
||||||
|
<%- if devise_mapping.confirmable? %>
|
||||||
|
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
|
||||||
|
<% end -%>
|
||||||
16
generators/devise_views/templates/passwords/new.html.erb
Normal file
16
generators/devise_views/templates/passwords/new.html.erb
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<h2>Forgot your password?</h2>
|
||||||
|
|
||||||
|
<% form_for resource_name, :url => password_path(resource_name) do |f| %>
|
||||||
|
<%= f.error_messages %>
|
||||||
|
|
||||||
|
<p><%= f.label :email %></p>
|
||||||
|
<p><%= f.text_field :email %></p>
|
||||||
|
|
||||||
|
<p><%= f.submit "Send me reset password instructions" %></p>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<%= link_to "Sign in", new_session_path(resource_name) %><br />
|
||||||
|
|
||||||
|
<%- if devise_mapping.confirmable? %>
|
||||||
|
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
|
||||||
|
<% end -%>
|
||||||
23
generators/devise_views/templates/sessions/new.html.erb
Normal file
23
generators/devise_views/templates/sessions/new.html.erb
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<h2>Sign in</h2>
|
||||||
|
|
||||||
|
<% form_for resource_name, :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 -%>
|
||||||
|
|
||||||
|
<%- if devise_mapping.recoverable? %>
|
||||||
|
<%= link_to "Forgot password?", new_password_path(resource_name) %><br />
|
||||||
|
<% end -%>
|
||||||
|
|
||||||
|
<%- if devise_mapping.confirmable? %>
|
||||||
|
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
|
||||||
|
<% end -%>
|
||||||
Reference in New Issue
Block a user