projects
/
selectricity-live
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
bef19cb
)
Added funcitionality so user can change the email address associated with their accou...
author
justin
<tr0phy13@gmail.com>
Thu, 14 Apr 2011 06:32:19 +0000
(23:32 -0700)
committer
justin
<tr0phy13@gmail.com>
Thu, 14 Apr 2011 06:32:19 +0000
(23:32 -0700)
app/controllers/account_controller.rb
patch
|
blob
|
history
app/models/user.rb
patch
|
blob
|
history
app/views/account/change_contact.rhtml
patch
|
blob
|
history
app/views/account/summary.rhtml
patch
|
blob
|
history
diff --git
a/app/controllers/account_controller.rb
b/app/controllers/account_controller.rb
index 51bd80500f424b0cdd7329d0b961286c118cacab..ce4303dde9694e64a1c00d9293ba291e5abcf85e 100644
(file)
--- a/
app/controllers/account_controller.rb
+++ b/
app/controllers/account_controller.rb
@@
-63,6
+63,15
@@
class AccountController < ApplicationController
@user = User.find(params[:id])
end
@user = User.find(params[:id])
end
+ def change_contact
+ @user = User.find(params[:id])
+ return unless request.post?
+ @user.email=params[:email]
+ @user.save!
+ flash[:notice] = "Email successfully updated"
+ render :action => 'summary'
+ end
+
end
end
diff --git
a/app/models/user.rb
b/app/models/user.rb
index 17fe702332970e51b7f1ecacb3e0627e70feb312..13588402064c996a69e018283ffa1dc5f4a63f61 100644
(file)
--- a/
app/models/user.rb
+++ b/
app/models/user.rb
@@
-25,6
+25,10
@@
class User < ActiveRecord::Base
def name
[ firstname, lastname].join(" ")
end
def name
[ firstname, lastname].join(" ")
end
+
+ def email=(new_email)
+ self[:email] = new_email
+ end
# Authenticates a user by their login name and unencrypted password. Returns the user or nil.
def self.authenticate(login, password)
# Authenticates a user by their login name and unencrypted password. Returns the user or nil.
def self.authenticate(login, password)
@@
-82,4
+86,5
@@
class User < ActiveRecord::Base
errors.add(:login, "should not begin or end with spaces") if login and login.strip!
errors.add(:login, "should contain only letters, numbers, and spaces") unless login =~ /^[A-Za-z0-9 ]*$/
end
errors.add(:login, "should not begin or end with spaces") if login and login.strip!
errors.add(:login, "should contain only letters, numbers, and spaces") unless login =~ /^[A-Za-z0-9 ]*$/
end
+
end
end
diff --git
a/app/views/account/change_contact.rhtml
b/app/views/account/change_contact.rhtml
index d8fa638eda7ede21fc6b0ae9b00853177a1a34f7..b16bc8b3954c51c900457f35aac82328d7e8214f 100644
(file)
--- a/
app/views/account/change_contact.rhtml
+++ b/
app/views/account/change_contact.rhtml
@@
-3,9
+3,11
@@
<span class="subheader"></span>
</div>
<div class="user_edit">
<span class="subheader"></span>
</div>
<div class="user_edit">
+ <p>Current E-mail: <%=h @user.email %></p>
+
<% form_tag do -%>
<% form_tag do -%>
- <p><label for="login">
Change
E-mail</label><br/>
+ <p><label for="login">
New
E-mail</label><br/>
<%= text_field_tag 'email' %></p>
<p><%= submit_tag 'Submit' %></p>
<%= text_field_tag 'email' %></p>
<p><%= submit_tag 'Submit' %></p>
diff --git
a/app/views/account/summary.rhtml
b/app/views/account/summary.rhtml
index 0ea9f241dcb729614205a6445581998fc1b3335a..61a4b24735d1d2d45cbbf299a955c3856b425230 100644
(file)
--- a/
app/views/account/summary.rhtml
+++ b/
app/views/account/summary.rhtml
@@
-10,6
+10,12
@@
E-mail: <%=h @user.email %><br />
Member since: <%=h @user.created_at.strftime("%x") %>
</p>
Member since: <%=h @user.created_at.strftime("%x") %>
</p>
+<p>
+ <%= link_to "Update Email Address", :action => 'change_contact',
+ :id => @user.id %>
+</p>
+
+
<p>Your Elections:
<table class="voterbox" id="election">
<tr>
<p>Your Elections:
<table class="voterbox" id="election">
<tr>
Benjamin Mako Hill
||
Want to submit a patch?