mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 15:49:55 +08:00
29 lines
782 B
Ruby
29 lines
782 B
Ruby
class BadgesController < ApplicationController
|
|
skip_before_filter :check_xhr, only: [:index, :show]
|
|
|
|
def index
|
|
badges = Badge.all.to_a
|
|
serialized = MultiJson.dump(serialize_data(badges, BadgeSerializer, root: "badges"))
|
|
respond_to do |format|
|
|
format.html do
|
|
store_preloaded "badges", serialized
|
|
render "default/empty"
|
|
end
|
|
format.json { render json: serialized }
|
|
end
|
|
end
|
|
|
|
def show
|
|
params.require(:id)
|
|
badge = Badge.find(params[:id])
|
|
serialized = MultiJson.dump(serialize_data(badge, BadgeSerializer, root: "badge"))
|
|
respond_to do |format|
|
|
format.html do
|
|
store_preloaded "badge", serialized
|
|
render "default/empty"
|
|
end
|
|
format.json { render json: serialized }
|
|
end
|
|
end
|
|
end
|