File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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"
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments