Created
October 26, 2012 17:47
-
-
Save joshsmith/3960217 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| %h2 Edit your profile | |
| = form_for @user, :html => { :class => "form-horizontal" } do |f| | |
| .control-group | |
| = f.label :first_name, :class => "control-label" | |
| .controls | |
| = f.text_field :first_name | |
| .control-group | |
| = f.label :last_name, :class => "control-label" | |
| .controls | |
| = f.text_field :last_name | |
| %span.help-block We like to use real names on Artburst, so people know who's who. | |
| .control-group | |
| = f.label :username, :class => "control-label" | |
| .controls | |
| = f.text_field :username | |
| %span.help-block Your Artburst profile will be here: http://artburst.com/<strong id="username">USERNAME</strong> | |
| .control-group | |
| = f.label :email, :class => "control-label" | |
| .controls | |
| .input-prepend | |
| %span.add-on | |
| %i.icon.icon-envelope | |
| = f.text_field :email | |
| .control-group | |
| = f.label :zip, "Zip code", :class => "control-label" | |
| .controls | |
| .input-prepend | |
| %span.add-on | |
| %i.icon.icon-map-marker | |
| = f.text_field :zip, :class => "input-mini" | |
| %span.help-block So we can help you find nearby events and artists. | |
| .control-group | |
| .controls | |
| = f.submit "Save Changes", :class => "btn btn-primary" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'spec_helper' | |
| feature 'Edit user profile' do | |
| before do | |
| @user = create(:user) | |
| login(@user) | |
| visit "/#{@user.username}/edit" | |
| end | |
| scenario 'Successful edit' do | |
| page.should have_content("Edit your profile") | |
| fill_in "First name", :with => "New" | |
| fill_in "Last name", :with => "Name" | |
| fill_in "Username", :with => "newusername" | |
| fill_in "Email", :with => "[email protected]" | |
| fill_in "Zip code", :with => "92104" | |
| click_button "Save Changes" | |
| page.should have_content("Your account has been updated.") | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class UsersController < ApplicationController | |
| def show | |
| @user = User.find_by_username!(params[:id].downcase) | |
| end | |
| def new | |
| end | |
| def edit | |
| @user = User.find_by_username!(params[:id].downcase) | |
| end | |
| def update | |
| @user = User.find(params[:id]) | |
| if @user.update_attributes(params[:user]) | |
| flash[:success] = "Your account has been updated." | |
| redirect_to edit_user_path(@user.username) | |
| else | |
| render 'edit' | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment