Commit b239ce7e9984fb0915ec90522de54a22337e53a3
1 parent
adca7cf0
Exists in
master
and in
2 other branches
rails_apps_composer: views
Showing
5 changed files
with
64 additions
and
0 deletions
Show diff stats
app/helpers/application_helper.rb
1 | module ApplicationHelper | 1 | module ApplicationHelper |
2 | + | ||
3 | + def display_base_errors resource | ||
4 | + return '' if (resource.errors.empty?) or (resource.errors[:base].empty?) | ||
5 | + messages = resource.errors[:base].map { |msg| content_tag(:p, msg) }.join | ||
6 | + html = <<-HTML | ||
7 | + <div class="alert alert-error alert-block"> | ||
8 | + <button type="button" class="close" data-dismiss="alert">×</button> | ||
9 | + #{messages} | ||
10 | + </div> | ||
11 | + HTML | ||
12 | + html.html_safe | ||
13 | + end | ||
14 | + | ||
2 | end | 15 | end |
@@ -0,0 +1,15 @@ | @@ -0,0 +1,15 @@ | ||
1 | +%h2 | ||
2 | + Edit #{resource_name.to_s.humanize} | ||
3 | += simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put, :class => 'form-vertical' }) do |f| | ||
4 | + = f.error_notification | ||
5 | + = display_base_errors resource | ||
6 | + = f.input :name, :autofocus => true | ||
7 | + = f.input :email, :required => true | ||
8 | + = f.input :password, :autocomplete => "off", :hint => "leave it blank if you don't want to change it", :required => false | ||
9 | + = f.input :password_confirmation, :required => false | ||
10 | + = f.input :current_password, :hint => "we need your current password to confirm your changes", :required => true | ||
11 | + = f.button :submit, 'Update', :class => 'btn-primary' | ||
12 | +%h3 Cancel my account | ||
13 | +%p | ||
14 | + Unhappy? #{link_to "Cancel my account", registration_path(resource_name), :data => { :confirm => "Are you sure?" }, :method => :delete}. | ||
15 | += link_to "Back", :back |
@@ -0,0 +1,10 @@ | @@ -0,0 +1,10 @@ | ||
1 | +%h2 Sign up | ||
2 | += simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => {:class => 'form-vertical' }) do |f| | ||
3 | + = f.error_notification | ||
4 | + = display_base_errors resource | ||
5 | + = f.input :name, :autofocus => true | ||
6 | + = f.input :email, :required => true | ||
7 | + = f.input :password, :required => true | ||
8 | + = f.input :password_confirmation, :required => true | ||
9 | + = f.button :submit, 'Sign up', :class => 'btn-primary' | ||
10 | += render "devise/shared/links" |
@@ -0,0 +1,7 @@ | @@ -0,0 +1,7 @@ | ||
1 | +%h2 Sign in | ||
2 | += simple_form_for(resource, :as => resource_name, :url => session_path(resource_name), :html => {:class => 'form-vertical' }) do |f| | ||
3 | + = f.input :email, :autofocus => true | ||
4 | + = f.input :password | ||
5 | + = f.input :remember_me, :as => :boolean if devise_mapping.rememberable? | ||
6 | + = f.button :submit, "Sign in", :class => 'btn-primary' | ||
7 | += render "devise/shared/links" |
@@ -0,0 +1,19 @@ | @@ -0,0 +1,19 @@ | ||
1 | +- if controller_name != 'sessions' | ||
2 | + = link_to "Sign in", new_session_path(resource_name) | ||
3 | + %br/ | ||
4 | +- if devise_mapping.registerable? && controller_name != 'registrations' | ||
5 | + = link_to "Sign up", new_registration_path(resource_name) | ||
6 | + %br/ | ||
7 | +- if devise_mapping.recoverable? && controller_name != 'passwords' | ||
8 | + = link_to "Forgot your password?", new_password_path(resource_name) | ||
9 | + %br/ | ||
10 | +- if devise_mapping.confirmable? && controller_name != 'confirmations' | ||
11 | + = link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) | ||
12 | + %br/ | ||
13 | +- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' | ||
14 | + = link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) | ||
15 | + %br/ | ||
16 | +- if devise_mapping.omniauthable? | ||
17 | + - resource_class.omniauth_providers.each do |provider| | ||
18 | + = link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) | ||
19 | + %br/ |