Created
March 30, 2011 21:54
-
-
Save craigmartin/895394 to your computer and use it in GitHub Desktop.
user.rb file for error reference
This file contains 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
get "/user/profile" do | |
haml :profile | |
end | |
get "/user/profile/change" do | |
haml :change_profile | |
end | |
post "/user/profile" do | |
unless @User.update(:nickname => params[:nickname], | |
:formatted_name => params[:formatted_name], | |
:location => params[:location], | |
:description => params[:description], | |
:sex => params[:sex], | |
:relationship_status => params[:relationship_status], | |
:interests => params[:interests], | |
:education => params[:education]) | |
flash[:error] = @user.errors.values.join(",") | |
redirect "/user/profile/change" | |
end | |
redirect "/" | |
end | |
post '/user/status' do | |
Status.create(:text => params[:status], :user => @user) | |
redirect "/" | |
end | |
post '/user/wall' do | |
Post.create(:text => params[:status], :user => @user, :wall_id => params[:wallid]) | |
redirect "/user/#{params[:nickname]}" | |
end | |
get "/user/:nickname" do | |
@myself = @user | |
@viewed_user = User.first(:nickname => params[:nickname]) | |
@viewing_self = (@viewed_user == @myself) | |
all = [] + @viewed_user.activities + @viewed_user.wall.posts | |
@all = all.sort {|x,y| y.created_at <=> x.created_at} | |
haml :user | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment