#The following methods are for selectricity specific uses
def summary
+ #@user = User.find(params[:id])
+
+ #constrain the find command such that it only returns the user if it's the currently
+ #logged in user, otherwise, redirect to the front page
+ id = params[:id]
+ user_id = session[:user][:id]
+ @user = User.find(id, :conditions => ["id = ?", user_id])
+
+ rescue
+ redirect_to :controller =>'front'
+
+ 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
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
--- /dev/null
+<div id="title-header">
+ <span class="header">Change E-mail</span>
+ <span class="subheader"></span>
+</div>
+<div class="user_edit">
+ <p>Current E-mail: <%=h @user.email %></p>
+
+ <% form_tag do -%>
+
+ <p><label for="login">New E-mail</label><br/>
+ <%= text_field_tag 'email' %></p>
+
+ <p><%= submit_tag 'Submit' %></p>
+ <% end -%>
+</div>
\ No newline at end of file
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>