simple_roles 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. data/.rspec +1 -0
  2. data/Gemfile +22 -0
  3. data/MIT-LICENSE +20 -0
  4. data/README.md +81 -0
  5. data/Rakefile +53 -0
  6. data/VERSION +1 -0
  7. data/app/assets/images/simple_roles/.gitkeep +0 -0
  8. data/app/assets/javascripts/simple_roles/.gitkeep +0 -0
  9. data/app/assets/stylesheets/simple_roles/.gitkeep +0 -0
  10. data/app/controllers/.gitkeep +0 -0
  11. data/app/helpers/.gitkeep +0 -0
  12. data/app/mailers/.gitkeep +0 -0
  13. data/app/models/.gitkeep +0 -0
  14. data/app/models/role.rb +4 -0
  15. data/app/models/user_role.rb +4 -0
  16. data/app/views/.gitkeep +0 -0
  17. data/config/routes.rb +2 -0
  18. data/db/migrate/001_create_user_roles.rb +15 -0
  19. data/db/migrate/002_create_roles.rb +22 -0
  20. data/lib/simple_roles/base.rb +111 -0
  21. data/lib/simple_roles/configuration.rb +33 -0
  22. data/lib/simple_roles/engine.rb +4 -0
  23. data/lib/simple_roles/macros.rb +13 -0
  24. data/lib/simple_roles/roles_array.rb +63 -0
  25. data/lib/simple_roles/version.rb +3 -0
  26. data/lib/simple_roles.rb +19 -0
  27. data/lib/tasks/simple_roles_tasks.rake +4 -0
  28. data/script/rails +6 -0
  29. data/simple_roles.gemspec +196 -0
  30. data/spec/dummy/Rakefile +7 -0
  31. data/spec/dummy/app/assets/javascripts/application.js +9 -0
  32. data/spec/dummy/app/assets/javascripts/default.js +2 -0
  33. data/spec/dummy/app/assets/javascripts/jquery.js +16 -0
  34. data/spec/dummy/app/assets/javascripts/jquery_ujs.js +169 -0
  35. data/spec/dummy/app/assets/javascripts/posts.js +2 -0
  36. data/spec/dummy/app/assets/stylesheets/application.css +7 -0
  37. data/spec/dummy/app/assets/stylesheets/default.css +4 -0
  38. data/spec/dummy/app/assets/stylesheets/posts.css +4 -0
  39. data/spec/dummy/app/assets/stylesheets/scaffold.css +56 -0
  40. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  41. data/spec/dummy/app/controllers/default_controller.rb +5 -0
  42. data/spec/dummy/app/controllers/posts_controller.rb +83 -0
  43. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  44. data/spec/dummy/app/helpers/default_helper.rb +2 -0
  45. data/spec/dummy/app/helpers/posts_helper.rb +2 -0
  46. data/spec/dummy/app/mailers/.gitkeep +0 -0
  47. data/spec/dummy/app/models/.gitkeep +0 -0
  48. data/spec/dummy/app/models/post.rb +2 -0
  49. data/spec/dummy/app/models/user.rb +15 -0
  50. data/spec/dummy/app/views/default/index.html.erb +4 -0
  51. data/spec/dummy/app/views/devise/confirmations/new.html.erb +12 -0
  52. data/spec/dummy/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
  53. data/spec/dummy/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
  54. data/spec/dummy/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
  55. data/spec/dummy/app/views/devise/passwords/edit.html.erb +16 -0
  56. data/spec/dummy/app/views/devise/passwords/new.html.erb +12 -0
  57. data/spec/dummy/app/views/devise/registrations/edit.html.erb +25 -0
  58. data/spec/dummy/app/views/devise/registrations/new.html.erb +18 -0
  59. data/spec/dummy/app/views/devise/sessions/new.html.erb +17 -0
  60. data/spec/dummy/app/views/devise/shared/_links.erb +25 -0
  61. data/spec/dummy/app/views/devise/unlocks/new.html.erb +12 -0
  62. data/spec/dummy/app/views/layouts/application.html.erb +15 -0
  63. data/spec/dummy/app/views/posts/_form.html.erb +17 -0
  64. data/spec/dummy/app/views/posts/edit.html.erb +6 -0
  65. data/spec/dummy/app/views/posts/index.html.erb +21 -0
  66. data/spec/dummy/app/views/posts/new.html.erb +5 -0
  67. data/spec/dummy/app/views/posts/show.html.erb +5 -0
  68. data/spec/dummy/config/application.rb +51 -0
  69. data/spec/dummy/config/boot.rb +10 -0
  70. data/spec/dummy/config/database.yml +26 -0
  71. data/spec/dummy/config/database_mysql.yml +29 -0
  72. data/spec/dummy/config/database_pgsql.yml +35 -0
  73. data/spec/dummy/config/environment.rb +5 -0
  74. data/spec/dummy/config/environments/development.rb +24 -0
  75. data/spec/dummy/config/environments/production.rb +52 -0
  76. data/spec/dummy/config/environments/test.rb +39 -0
  77. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  78. data/spec/dummy/config/initializers/devise.rb +204 -0
  79. data/spec/dummy/config/initializers/inflections.rb +10 -0
  80. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  81. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  82. data/spec/dummy/config/initializers/session_store.rb +8 -0
  83. data/spec/dummy/config/initializers/simple_roles.rb +3 -0
  84. data/spec/dummy/config/initializers/wrap_parameters.rb +12 -0
  85. data/spec/dummy/config/locales/devise.en.yml +53 -0
  86. data/spec/dummy/config/locales/en.yml +5 -0
  87. data/spec/dummy/config/routes.rb +13 -0
  88. data/spec/dummy/config.ru +4 -0
  89. data/spec/dummy/db/migrate/010_devise_create_users.rb +29 -0
  90. data/spec/dummy/db/migrate/20110925210726_create_user_roles.rb +15 -0
  91. data/spec/dummy/db/migrate/20110925210727_create_roles.rb +22 -0
  92. data/spec/dummy/db/schema.rb +51 -0
  93. data/spec/dummy/db/seeds.rb +14 -0
  94. data/spec/dummy/log/.gitkeep +0 -0
  95. data/spec/dummy/public/404.html +26 -0
  96. data/spec/dummy/public/422.html +26 -0
  97. data/spec/dummy/public/500.html +26 -0
  98. data/spec/dummy/public/favicon.ico +0 -0
  99. data/spec/dummy/script/rails +6 -0
  100. data/spec/dummy/test/fixtures/posts.yml +11 -0
  101. data/spec/dummy/test/fixtures/users.yml +11 -0
  102. data/spec/dummy/test/functional/default_controller_test.rb +9 -0
  103. data/spec/dummy/test/functional/posts_controller_test.rb +49 -0
  104. data/spec/dummy/test/unit/helpers/default_helper_test.rb +4 -0
  105. data/spec/dummy/test/unit/helpers/posts_helper_test.rb +4 -0
  106. data/spec/dummy/test/unit/post_test.rb +7 -0
  107. data/spec/dummy/test/unit/user_test.rb +7 -0
  108. data/spec/dummy_spec_helper.rb +41 -0
  109. data/spec/integration/main_spec.rb +7 -0
  110. data/spec/integration/messages_spec.rb +62 -0
  111. data/spec/integration/requests/main_spec.rb +21 -0
  112. data/spec/simple_roles/base_spec.rb +191 -0
  113. data/spec/simple_roles/macros_spec.rb +25 -0
  114. data/spec/spec_helper.rb +52 -0
  115. data/spec/support/aliases.rb +0 -0
  116. data/spec/support/controller_macros.rb +26 -0
  117. data/spec/support/database.yml +6 -0
  118. data/spec/support/factories.rb +22 -0
  119. data/spec/support/fixtures/models/.gitkeep +0 -0
  120. data/spec/support/fixtures/models/user.rb +3 -0
  121. data/spec/support/migrations/010_create_users.rb +14 -0
  122. data/spec/support/rspec_helpers.rb +22 -0
  123. metadata +320 -0
@@ -0,0 +1,169 @@
1
+ /**
2
+ * Unobtrusive scripting adapter for jQuery
3
+ *
4
+ * Requires jQuery 1.4.3 or later.
5
+ * https://github.com/rails/jquery-ujs
6
+ */
7
+
8
+ (function($) {
9
+ // Make sure that every Ajax request sends the CSRF token
10
+ function CSRFProtection(fn) {
11
+ var token = $('meta[name="csrf-token"]').attr('content');
12
+ if (token) fn(function(xhr) { xhr.setRequestHeader('X-CSRF-Token', token) });
13
+ }
14
+ if ($().jquery == '1.5') { // gruesome hack
15
+ var factory = $.ajaxSettings.xhr;
16
+ $.ajaxSettings.xhr = function() {
17
+ var xhr = factory();
18
+ CSRFProtection(function(setHeader) {
19
+ var open = xhr.open;
20
+ xhr.open = function() { open.apply(this, arguments); setHeader(this) };
21
+ });
22
+ return xhr;
23
+ };
24
+ }
25
+ else $(document).ajaxSend(function(e, xhr) {
26
+ CSRFProtection(function(setHeader) { setHeader(xhr) });
27
+ });
28
+
29
+ // Triggers an event on an element and returns the event result
30
+ function fire(obj, name, data) {
31
+ var event = new $.Event(name);
32
+ obj.trigger(event, data);
33
+ return event.result !== false;
34
+ }
35
+
36
+ // Submits "remote" forms and links with ajax
37
+ function handleRemote(element) {
38
+ var method, url, data,
39
+ dataType = element.attr('data-type') || ($.ajaxSettings && $.ajaxSettings.dataType);
40
+
41
+ if (element.is('form')) {
42
+ method = element.attr('method');
43
+ url = element.attr('action');
44
+ data = element.serializeArray();
45
+ // memoized value from clicked submit button
46
+ var button = element.data('ujs:submit-button');
47
+ if (button) {
48
+ data.push(button);
49
+ element.data('ujs:submit-button', null);
50
+ }
51
+ } else {
52
+ method = element.attr('data-method');
53
+ url = element.attr('href');
54
+ data = null;
55
+ }
56
+
57
+ $.ajax({
58
+ url: url, type: method || 'GET', data: data, dataType: dataType,
59
+ // stopping the "ajax:beforeSend" event will cancel the ajax request
60
+ beforeSend: function(xhr, settings) {
61
+ if (settings.dataType === undefined) {
62
+ xhr.setRequestHeader('accept', '*/*;q=0.5, ' + settings.accepts.script);
63
+ }
64
+ return fire(element, 'ajax:beforeSend', [xhr, settings]);
65
+ },
66
+ success: function(data, status, xhr) {
67
+ element.trigger('ajax:success', [data, status, xhr]);
68
+ },
69
+ complete: function(xhr, status) {
70
+ element.trigger('ajax:complete', [xhr, status]);
71
+ },
72
+ error: function(xhr, status, error) {
73
+ element.trigger('ajax:error', [xhr, status, error]);
74
+ }
75
+ });
76
+ }
77
+
78
+ // Handles "data-method" on links such as:
79
+ // <a href="/users/5" data-method="delete" rel="nofollow" data-confirm="Are you sure?">Delete</a>
80
+ function handleMethod(link) {
81
+ var href = link.attr('href'),
82
+ method = link.attr('data-method'),
83
+ csrf_token = $('meta[name=csrf-token]').attr('content'),
84
+ csrf_param = $('meta[name=csrf-param]').attr('content'),
85
+ form = $('<form method="post" action="' + href + '"></form>'),
86
+ metadata_input = '<input name="_method" value="' + method + '" type="hidden" />';
87
+
88
+ if (csrf_param !== undefined && csrf_token !== undefined) {
89
+ metadata_input += '<input name="' + csrf_param + '" value="' + csrf_token + '" type="hidden" />';
90
+ }
91
+
92
+ form.hide().append(metadata_input).appendTo('body');
93
+ form.submit();
94
+ }
95
+
96
+ function disableFormElements(form) {
97
+ form.find('input[data-disable-with]').each(function() {
98
+ var input = $(this);
99
+ input.data('ujs:enable-with', input.val())
100
+ .val(input.attr('data-disable-with'))
101
+ .attr('disabled', 'disabled');
102
+ });
103
+ }
104
+
105
+ function enableFormElements(form) {
106
+ form.find('input[data-disable-with]').each(function() {
107
+ var input = $(this);
108
+ input.val(input.data('ujs:enable-with')).removeAttr('disabled');
109
+ });
110
+ }
111
+
112
+ function allowAction(element) {
113
+ var message = element.attr('data-confirm');
114
+ return !message || (fire(element, 'confirm') && confirm(message));
115
+ }
116
+
117
+ function requiredValuesMissing(form) {
118
+ var missing = false;
119
+ form.find('input[name][required]').each(function() {
120
+ if (!$(this).val()) missing = true;
121
+ });
122
+ return missing;
123
+ }
124
+
125
+ $('a[data-confirm], a[data-method], a[data-remote]').live('click.rails', function(e) {
126
+ var link = $(this);
127
+ if (!allowAction(link)) return false;
128
+
129
+ if (link.attr('data-remote') != undefined) {
130
+ handleRemote(link);
131
+ return false;
132
+ } else if (link.attr('data-method')) {
133
+ handleMethod(link);
134
+ return false;
135
+ }
136
+ });
137
+
138
+ $('form').live('submit.rails', function(e) {
139
+ var form = $(this), remote = form.attr('data-remote') != undefined;
140
+ if (!allowAction(form)) return false;
141
+
142
+ // skip other logic when required values are missing
143
+ if (requiredValuesMissing(form)) return !remote;
144
+
145
+ if (remote) {
146
+ handleRemote(form);
147
+ return false;
148
+ } else {
149
+ // slight timeout so that the submit button gets properly serialized
150
+ setTimeout(function(){ disableFormElements(form) }, 13);
151
+ }
152
+ });
153
+
154
+ $('form input[type=submit], form button[type=submit], form button:not([type])').live('click.rails', function() {
155
+ var button = $(this);
156
+ if (!allowAction(button)) return false;
157
+ // register the pressed submit button
158
+ var name = button.attr('name'), data = name ? {name:name, value:button.val()} : null;
159
+ button.closest('form').data('ujs:submit-button', data);
160
+ });
161
+
162
+ $('form').live('ajax:beforeSend.rails', function(event) {
163
+ if (this == event.target) disableFormElements($(this));
164
+ });
165
+
166
+ $('form').live('ajax:complete.rails', function(event) {
167
+ if (this == event.target) enableFormElements($(this));
168
+ });
169
+ })( jQuery );
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,7 @@
1
+ /*
2
+ * This is a manifest file that'll automatically include all the stylesheets available in this directory
3
+ * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
4
+ * the top of the compiled file, but it's generally better to create a new file per style scope.
5
+ *= require_self
6
+ *= require_tree .
7
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,56 @@
1
+ body { background-color: #fff; color: #333; }
2
+
3
+ body, p, ol, ul, td {
4
+ font-family: verdana, arial, helvetica, sans-serif;
5
+ font-size: 13px;
6
+ line-height: 18px;
7
+ }
8
+
9
+ pre {
10
+ background-color: #eee;
11
+ padding: 10px;
12
+ font-size: 11px;
13
+ }
14
+
15
+ a { color: #000; }
16
+ a:visited { color: #666; }
17
+ a:hover { color: #fff; background-color:#000; }
18
+
19
+ div.field, div.actions {
20
+ margin-bottom: 10px;
21
+ }
22
+
23
+ #notice {
24
+ color: green;
25
+ }
26
+
27
+ .field_with_errors {
28
+ padding: 2px;
29
+ background-color: red;
30
+ display: table;
31
+ }
32
+
33
+ #error_explanation {
34
+ width: 450px;
35
+ border: 2px solid red;
36
+ padding: 7px;
37
+ padding-bottom: 0;
38
+ margin-bottom: 20px;
39
+ background-color: #f0f0f0;
40
+ }
41
+
42
+ #error_explanation h2 {
43
+ text-align: left;
44
+ font-weight: bold;
45
+ padding: 5px 5px 5px 15px;
46
+ font-size: 12px;
47
+ margin: -7px;
48
+ margin-bottom: 0px;
49
+ background-color: #c00;
50
+ color: #fff;
51
+ }
52
+
53
+ #error_explanation ul li {
54
+ font-size: 12px;
55
+ list-style: square;
56
+ }
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+
4
+ before_filter :authenticate_user!
5
+ end
@@ -0,0 +1,5 @@
1
+ class DefaultController < ApplicationController
2
+ def index
3
+ end
4
+
5
+ end
@@ -0,0 +1,83 @@
1
+ class PostsController < ApplicationController
2
+ # GET /posts
3
+ # GET /posts.json
4
+ def index
5
+ @posts = Post.all
6
+
7
+ respond_to do |format|
8
+ format.html # index.html.erb
9
+ format.json { render json: @posts }
10
+ end
11
+ end
12
+
13
+ # GET /posts/1
14
+ # GET /posts/1.json
15
+ def show
16
+ @post = Post.find(params[:id])
17
+
18
+ respond_to do |format|
19
+ format.html # show.html.erb
20
+ format.json { render json: @post }
21
+ end
22
+ end
23
+
24
+ # GET /posts/new
25
+ # GET /posts/new.json
26
+ def new
27
+ @post = Post.new
28
+
29
+ respond_to do |format|
30
+ format.html # new.html.erb
31
+ format.json { render json: @post }
32
+ end
33
+ end
34
+
35
+ # GET /posts/1/edit
36
+ def edit
37
+ @post = Post.find(params[:id])
38
+ end
39
+
40
+ # POST /posts
41
+ # POST /posts.json
42
+ def create
43
+ @post = Post.new(params[:post])
44
+
45
+ respond_to do |format|
46
+ if @post.save
47
+ format.html { redirect_to @post, notice: 'Post was successfully created.' }
48
+ format.json { render json: @post, status: :created, location: @post }
49
+ else
50
+ format.html { render action: "new" }
51
+ format.json { render json: @post.errors, status: :unprocessable_entity }
52
+ end
53
+ end
54
+ end
55
+
56
+ # PUT /posts/1
57
+ # PUT /posts/1.json
58
+ def update
59
+ @post = Post.find(params[:id])
60
+
61
+ respond_to do |format|
62
+ if @post.update_attributes(params[:post])
63
+ format.html { redirect_to @post, notice: 'Post was successfully updated.' }
64
+ format.json { head :ok }
65
+ else
66
+ format.html { render action: "edit" }
67
+ format.json { render json: @post.errors, status: :unprocessable_entity }
68
+ end
69
+ end
70
+ end
71
+
72
+ # DELETE /posts/1
73
+ # DELETE /posts/1.json
74
+ def destroy
75
+ @post = Post.find(params[:id])
76
+ @post.destroy
77
+
78
+ respond_to do |format|
79
+ format.html { redirect_to posts_url }
80
+ format.json { head :ok }
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module DefaultHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module PostsHelper
2
+ end
File without changes
File without changes
@@ -0,0 +1,2 @@
1
+ class Post < ActiveRecord::Base
2
+ end
@@ -0,0 +1,15 @@
1
+ class User < ActiveRecord::Base
2
+
3
+
4
+ simple_roles
5
+
6
+ devise :database_authenticatable, :registerable,
7
+ :recoverable, :rememberable, :trackable, :validatable
8
+
9
+ # Setup accessible (or protected) attributes for your model
10
+ # DEVISE
11
+ attr_accessible :email, :password, :password_confirmation, :remember_me
12
+
13
+ # OTHER
14
+ attr_accessible :name, :username
15
+ end
@@ -0,0 +1,4 @@
1
+ <h1>Default#index</h1>
2
+ <p>Find me in app/views/default/index.html.erb</p>
3
+
4
+
@@ -0,0 +1,12 @@
1
+ <h2>Resend confirmation instructions</h2>
2
+
3
+ <%= form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post }) do |f| %>
4
+ <%= devise_error_messages! %>
5
+
6
+ <p><%= f.label :email %><br />
7
+ <%= f.email_field :email %></p>
8
+
9
+ <p><%= f.submit "Resend confirmation instructions" %></p>
10
+ <% end %>
11
+
12
+ <%= render :partial => "devise/shared/links" %>
@@ -0,0 +1,5 @@
1
+ <p>Welcome <%= @resource.email %>!</p>
2
+
3
+ <p>You can confirm your account through the link below:</p>
4
+
5
+ <p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %></p>
@@ -0,0 +1,8 @@
1
+ <p>Hello <%= @resource.email %>!</p>
2
+
3
+ <p>Someone has requested a link to change your password, and you can do this through the link below.</p>
4
+
5
+ <p><%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %></p>
6
+
7
+ <p>If you didn't request this, please ignore this email.</p>
8
+ <p>Your password won't change until you access the link above and create a new one.</p>
@@ -0,0 +1,7 @@
1
+ <p>Hello <%= @resource.email %>!</p>
2
+
3
+ <p>Your account has been locked due to an excessive amount of unsuccessful sign in attempts.</p>
4
+
5
+ <p>Click the link below to unlock your account:</p>
6
+
7
+ <p><%= link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @resource.unlock_token) %></p>
@@ -0,0 +1,16 @@
1
+ <h2>Change your password</h2>
2
+
3
+ <%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put }) do |f| %>
4
+ <%= devise_error_messages! %>
5
+ <%= f.hidden_field :reset_password_token %>
6
+
7
+ <p><%= f.label :password, "New password" %><br />
8
+ <%= f.password_field :password %></p>
9
+
10
+ <p><%= f.label :password_confirmation, "Confirm new password" %><br />
11
+ <%= f.password_field :password_confirmation %></p>
12
+
13
+ <p><%= f.submit "Change my password" %></p>
14
+ <% end %>
15
+
16
+ <%= render :partial => "devise/shared/links" %>
@@ -0,0 +1,12 @@
1
+ <h2>Forgot your password?</h2>
2
+
3
+ <%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post }) do |f| %>
4
+ <%= devise_error_messages! %>
5
+
6
+ <p><%= f.label :email %><br />
7
+ <%= f.email_field :email %></p>
8
+
9
+ <p><%= f.submit "Send me reset password instructions" %></p>
10
+ <% end %>
11
+
12
+ <%= render :partial => "devise/shared/links" %>
@@ -0,0 +1,25 @@
1
+ <h2>Edit <%= resource_name.to_s.humanize %></h2>
2
+
3
+ <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
4
+ <%= devise_error_messages! %>
5
+
6
+ <p><%= f.label :email %><br />
7
+ <%= f.email_field :email %></p>
8
+
9
+ <p><%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
10
+ <%= f.password_field :password %></p>
11
+
12
+ <p><%= f.label :password_confirmation %><br />
13
+ <%= f.password_field :password_confirmation %></p>
14
+
15
+ <p><%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
16
+ <%= f.password_field :current_password %></p>
17
+
18
+ <p><%= f.submit "Update" %></p>
19
+ <% end %>
20
+
21
+ <h3>Cancel my account</h3>
22
+
23
+ <p>Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete %>.</p>
24
+
25
+ <%= link_to "Back", :back %>
@@ -0,0 +1,18 @@
1
+ <h2>Sign up</h2>
2
+
3
+ <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
4
+ <%= devise_error_messages! %>
5
+
6
+ <p><%= f.label :email %><br />
7
+ <%= f.email_field :email %></p>
8
+
9
+ <p><%= f.label :password %><br />
10
+ <%= f.password_field :password %></p>
11
+
12
+ <p><%= f.label :password_confirmation %><br />
13
+ <%= f.password_field :password_confirmation %></p>
14
+
15
+ <p><%= f.submit "Sign up" %></p>
16
+ <% end %>
17
+
18
+ <%= render :partial => "devise/shared/links" %>
@@ -0,0 +1,17 @@
1
+ <h2>Sign in</h2>
2
+
3
+ <%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
4
+ <p><%= f.label :email %><br />
5
+ <%= f.email_field :email %></p>
6
+
7
+ <p><%= f.label :password %><br />
8
+ <%= f.password_field :password %></p>
9
+
10
+ <% if devise_mapping.rememberable? -%>
11
+ <p><%= f.check_box :remember_me %> <%= f.label :remember_me %></p>
12
+ <% end -%>
13
+
14
+ <p><%= f.submit "Sign in" %></p>
15
+ <% end %>
16
+
17
+ <%= render :partial => "devise/shared/links" %>
@@ -0,0 +1,25 @@
1
+ <%- if controller_name != 'sessions' %>
2
+ <%= link_to "Sign in", new_session_path(resource_name) %><br />
3
+ <% end -%>
4
+
5
+ <%- if devise_mapping.registerable? && controller_name != 'registrations' %>
6
+ <%= link_to "Sign up", new_registration_path(resource_name) %><br />
7
+ <% end -%>
8
+
9
+ <%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
10
+ <%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
11
+ <% end -%>
12
+
13
+ <%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
14
+ <%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
15
+ <% end -%>
16
+
17
+ <%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
18
+ <%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
19
+ <% end -%>
20
+
21
+ <%- if devise_mapping.omniauthable? %>
22
+ <%- resource_class.omniauth_providers.each do |provider| %>
23
+ <%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %><br />
24
+ <% end -%>
25
+ <% end -%>
@@ -0,0 +1,12 @@
1
+ <h2>Resend unlock instructions</h2>
2
+
3
+ <%= form_for(resource, :as => resource_name, :url => unlock_path(resource_name), :html => { :method => :post }) do |f| %>
4
+ <%= devise_error_messages! %>
5
+
6
+ <p><%= f.label :email %><br />
7
+ <%= f.email_field :email %></p>
8
+
9
+ <p><%= f.submit "Resend unlock instructions" %></p>
10
+ <% end %>
11
+
12
+ <%= render :partial => "devise/shared/links" %>
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag "application" %>
6
+ <%= javascript_include_tag "application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ <%= link_to 'Sign out', destroy_user_session_path, :method => :delete %>
14
+ </body>
15
+ </html>
@@ -0,0 +1,17 @@
1
+ <%= form_for(@post) do |f| %>
2
+ <% if @post.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @post.errors.full_messages.each do |msg| %>
8
+ <li><%= msg %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="actions">
15
+ <%= f.submit %>
16
+ </div>
17
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h1>Editing post</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', @post %> |
6
+ <%= link_to 'Back', posts_path %>
@@ -0,0 +1,21 @@
1
+ <h1>Listing posts</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <th></th>
6
+ <th></th>
7
+ <th></th>
8
+ </tr>
9
+
10
+ <% @posts.each do |post| %>
11
+ <tr>
12
+ <td><%= link_to 'Show', post %></td>
13
+ <td><%= link_to 'Edit', edit_post_path(post) %></td>
14
+ <td><%= link_to 'Destroy', post, confirm: 'Are you sure?', method: :delete %></td>
15
+ </tr>
16
+ <% end %>
17
+ </table>
18
+
19
+ <br />
20
+
21
+ <%= link_to 'New Post', new_post_path %>
@@ -0,0 +1,5 @@
1
+ <h1>New post</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', posts_path %>
@@ -0,0 +1,5 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+
4
+ <%= link_to 'Edit', edit_post_path(@post) %> |
5
+ <%= link_to 'Back', posts_path %>