name /u/:username route

This commit is contained in:
joshua stein 2014-01-12 14:22:47 -06:00
parent 93759f2187
commit 68a1f02a1c
3 changed files with 6 additions and 2 deletions

View file

@ -1,6 +1,6 @@
class UsersController < ApplicationController
def show
@showing_user = User.where(:username => params[:id]).first!
@showing_user = User.where(:username => params[:username]).first!
@title = "User #{@showing_user.username}"
end

View file

@ -123,6 +123,10 @@ class User < ActiveRecord::Base
Keystore.value_for("user:#{self.id}:stories_submitted").to_i
end
def to_param
username
end
def undeleted_received_messages
received_messages.where(:deleted_by_recipient => false)
end

View file

@ -68,7 +68,7 @@ Lobsters::Application.routes.draw do
get "/s/:id/(:title)" => "stories#show"
get "/u" => "users#tree"
get "/u/:id" => "users#show", :as => "user"
get "/u/:username" => "users#show", :as => "user"
get "/settings" => "settings#index"
post "/settings" => "settings#update"