Skip to content

Commit

Permalink
Add user link helpers that don't need an instantiated user.
Browse files Browse the repository at this point in the history
  • Loading branch information
nuclearsandwich committed Oct 25, 2011
1 parent e97f891 commit e3cd124
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 7 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
module ApplicationHelper
def username_program_slug_path username, program_slug
"/users/#{username}/programs/#{program_slug}"
end

def username_path username
"/users/#{username}"
end
end
3 changes: 1 addition & 2 deletions app/views/programs/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,4 @@ Here it is: every single program we've got. Check them out!

%ul
- collection.each do |program|
- user = User.find_by_username(program.author_username)
%li #{link_to program.title, user_program_path(user.username, program)}, by #{link_to user.username, user_path(user.username)}
%li #{link_to program.title, username_program_slug_path(program.author_username, program.slug)}, by #{link_to program.author_username, username_path(program.author_username)}

0 comments on commit e3cd124

Please sign in to comment.