Skip to content

Instantly share code, notes, and snippets.

@craigmartin
Created April 1, 2011 21:16
Show Gist options
  • Save craigmartin/898874 to your computer and use it in GitHub Desktop.
Save craigmartin/898874 to your computer and use it in GitHub Desktop.
this is the current user.rb -- changed unless @user.update_or_create to unless User.update_or_create
get "/user/profile" do
haml :profile
end
get "/user/profile/change" do
haml :change_profile
end
post "/user/profile" do
# unless @user.create(: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])
# end
unless User.update_or_create( :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