Skip to content

Commit ad89e25

Browse files
committed
Fixing it up
1 parent 8764f9e commit ad89e25

3 files changed

Lines changed: 15 additions & 18 deletions

File tree

app/controllers/questions_controller.rb

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,18 @@ def update
1919
params[:question][:solution_id] != @question.solution_id ? update!(:notice => "Okay! We've selected that answer") : update!
2020
end
2121

22+
def feed
23+
@title = "Questions Feed"
24+
25+
@questions = Question.sort(:created_at.desc).limit(20).all
26+
27+
@updated = @questions.first.updated_at
28+
29+
respond_to do |format|
30+
format.atom
31+
end
32+
end
33+
2234
def collection
2335
@questions = @presenter.apply_scope(end_of_association_chain).newest_first.paginate(:page => params[:page])
2436
end
@@ -66,18 +78,4 @@ def set_presenter
6678
end
6779
end
6880

69-
def feed
70-
@title = "Questions Feed"
71-
72-
@questions = Question.all(:select => "title, description, solution_id, created_at", :order => "created_at DESC", :limit => 20) unless @support
73-
74-
@updated = @questions.first.updated_at unless @questions.empty?
75-
76-
respond_to do |format|
77-
format.html
78-
format.atom
79-
format.xml { render :xml => @questions }
80-
end
81-
end
82-
8381
end

app/views/layouts/application.html.haml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
!!!
33
%html
44
%head
5-
= auto_discovery_link_tag :atom, feed_path
6-
= auto_discovery_link_tag :rss, feed_path
5+
= auto_discovery_link_tag :atom, "/questions/feed.atom" # I don't even care
76

87
- title = yield :title
98
%title #{title.blank? ? "" : "#{title} | "}Hackety Hack!

config/routes.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
resources :lessons, :only => [:index, :show]
44

55
resources :questions do
6-
match '/feed' => 'questions#feed',
6+
match 'feed' => 'questions#feed',
77
:as => :feed,
8-
:defaults => { :format => 'atom' }
8+
:on => :collection
99
end
1010

1111
resources :questions do

0 commit comments

Comments
 (0)