Skip to content

Commit 6d8762a

Browse files
committed
Added timestamps. Some styling.
1 parent eb0325f commit 6d8762a

4 files changed

Lines changed: 29 additions & 7 deletions

File tree

controllers/forums.rb

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,23 @@
1111
#we use this in the view
1212
@forum = params[:forum]
1313

14+
#this is kind of an ugly way to do this.
15+
@forum_name,
16+
@forum_description =
17+
case @forum
18+
when 'learning_ruby'
19+
["Learning Ruby",
20+
"A place to learn about the Ruby programming language."]
21+
when 'hackety_help'
22+
["Hackety Help",
23+
"Have a question about Hackety? You're in the right place!"]
24+
when 'clubhouse'
25+
["The Clubhouse",
26+
"A place to talk to other Hackers about anything you'd like to talk about."]
27+
end
28+
1429
#gotta find all the discussions in this forum
15-
@discussions = Discussion.all(:forum => params[:forum])
30+
@discussions = Discussion.all(:forum => params[:forum]).sort{|a,b| a.updated_at <=> b.updated_at}.reverse
1631

1732
#render the template!
1833
haml :"forums/show"

models/discussion.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ class Discussion
2121
#this is the slug for the url
2222
key :slug, String
2323

24+
timestamps!
25+
2426
before_save :make_slug
2527
validate_on_create :author_check
2628

views/discussions/show.haml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
%p{:style => "float:left;padding-right:1em"}
2+
%img{:src => gravatar_url_for(@discussion.author)}
13
%h1= @discussion.title
2-
%p #{@discussion.author} says:
4+
%p{:style => "padding-bottom:1em"} By <a href="/hackers/#{@discussion.author}">#{@discussion.author}</a>
35

46
%p= @discussion.body
57

views/forums/show.haml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
%ul
2-
- @discussions.each do |discussion|
3-
%li
4-
%a{ :href => "/forums/#{@forum}/#{discussion.slug}" }= discussion.title
5-
1+
%h1 Hackety Hack Forums: #{@forum_name}
2+
%p{:style => "padding-top:1em;padding-bottom:1em"}= @forum_description
63
- unless current_user.nil?
74
%a{:href => "/forums/#{@forum}/discussions/new"} New Discussion
5+
%ol
6+
- @discussions.each do |discussion|
7+
%li
8+
%a{ :href => "/forums/#{@forum}/#{discussion.slug}" }= discussion.title
9+
(posted by <a href="/hackers/#{discussion.author}">#{discussion.author}</a>)
10+
811

912
%a{ :href => "/forums" } Back to Forum List

0 commit comments

Comments
 (0)