From b3b954df343c0a38d24a3d6cb4f35c2460fc8b04 Mon Sep 17 00:00:00 2001 From: Ricky Barrette Date: Tue, 22 Jan 2013 11:38:35 -0500 Subject: [PATCH] Started cleanup user forms the cancel button on user cp is not working yet. before_filter not called? --- app/controllers/users_controller.rb | 7 +++++++ app/views/devise/registrations/edit.html.erb | 11 +++++------ app/views/devise/registrations/new.html.erb | 2 +- app/views/devise/sessions/new.html.erb | 2 +- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 4d2c251..ccd6d01 100755 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,5 +1,6 @@ class UsersController < ApplicationController + before_filter :check_for_cancel before_filter :authenticate_user! before_filter :is_admin? @@ -92,4 +93,10 @@ class UsersController < ApplicationController redirect_to root_path end end + + def check_for_cancel + if params[:commit] == 'cancel' + redirect_to :back + end + end end diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index 8ee1857..fd5181b 100755 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -15,11 +15,10 @@

<%= f.label :current_password %> (we need your current password to confirm your changes)
<%= f.password_field :current_password %>

-

<%= f.submit "Update" %>

+

+ <%= f.submit "Update", :class=> 'btn btn-primary'%> <%= button_tag "Cancel", :confirm => 'Are you sure? Any changes will be lost.', :class => 'btn', :type => 'submit', :name => 'commit', :value => 'cancel' %> +

<% end %> -

Cancel my account

- -

Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete %>.

- -<%= link_to "Back", :back %> +

Unhappy?

+<%= button_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete, :class =>'btn btn-danger' %> diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb index 0c1c1b5..85942b5 100755 --- a/app/views/devise/registrations/new.html.erb +++ b/app/views/devise/registrations/new.html.erb @@ -22,7 +22,7 @@ Confirm Password:
<%= f.password_field :password_confirmation, :autocomplete => "off" %>

-

<%= f.submit "Sign up" %>

+

<%= f.submit "Sign up", :class=> 'btn btn-primary' %>

<% end %>
diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index d627f77..4de1bc8 100755 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -26,7 +26,7 @@ <%= form_for("user", :url => user_session_path) do |f| %>

<%= f.text_field :username , :value => "username" %>

<%= f.password_field :password, :value => "password" %>

- <%= f.submit 'Sign in' %> + <%= f.submit 'Sign in', :class =>'btn btn-primary' %> <% end %>