Skip to content

Commit 937d0a5

Browse files
committed
Added user pages.
Each user now has a page at /hackers/:username
1 parent 4908bb6 commit 937d0a5

6 files changed

Lines changed: 12 additions & 0 deletions

File tree

controllers/hacker.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
get '/hackers/:name' do
2+
@hacker = User.first(:username => params[:name])
3+
haml :"hackers/show"
4+
end
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

features/support/paths.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ def path_to(page_name)
3636
"/signup"
3737
when /the main page/
3838
"/"
39+
when /the hacker page for "(.*)"/
40+
"/hackers/#{$1}"
3941

4042
# Add more mappings here.
4143
# Here is an example that pulls values out of the Regexp:

features/user.feature

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@ Feature: User management
2020
When I press "Create account"
2121
Then I should see "There were some problems"
2222
And I should be on the new user page
23+
Scenario: User pages
24+
Given there's a user with the username "steve"
25+
When I go to the hacker page for "steve"
26+
Then I should see "steve's page"

views/hackers/show.haml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
%p= @hacker.username + "'s page"

0 commit comments

Comments
 (0)