aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2015-12-08 23:52:53 +0900
committerKazuki Yamaguchi <k@rhe.jp>2015-12-08 23:52:53 +0900
commitba9e6119ddbe1a24a4c9c01abdb161f6641e2748 (patch)
tree9d18e4199f8c5028a1d9a452fd307fc8a7d2f856 /app
parent675512791a589990865405db9399be1ba31ed1c7 (diff)
downloadaclog-ba9e6119ddbe1a24a4c9c01abdb161f6641e2748.tar.gz
app: fix atom feed
Diffstat (limited to 'app')
-rw-r--r--app/controllers/application_controller.rb13
-rw-r--r--app/controllers/tweets_controller.rb4
2 files changed, 13 insertions, 4 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index a3c86f3..402efee 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -50,13 +50,18 @@ class ApplicationController < ActionController::Base
end
def force_json
- request.format = :json unless params[:format] == :atom
+ request.format = :json unless request.format.atom?
end
alias __render__ render
-
- def render(*args)
- raise ArgumentError, "don't use render, use render_json"
+ if Rails.env.development?
+ def render(*args)
+ if request.format.atom?
+ super(*args)
+ else
+ raise ArgumentError, "don't use render, use render_json"
+ end
+ end
end
def render_json(data:, **kwargs)
diff --git a/app/controllers/tweets_controller.rb b/app/controllers/tweets_controller.rb
index 018c19b..5faefdc 100644
--- a/app/controllers/tweets_controller.rb
+++ b/app/controllers/tweets_controller.rb
@@ -76,6 +76,10 @@ class TweetsController < ApplicationController
end
def render_tweets
+ if request.format.atom?
+ return render("tweets")
+ end
+
hash = {
user: @user.as_json(methods: :registered),
statuses: @tweets.map(&method(:transform_tweet)) }