@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
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)
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
<span class="subheader"></span>
</div>
<div class="user_edit">
+ <p>Current E-mail: <%=h @user.email %></p>
+
<% 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>
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>