This repository has been archived on 2025-05-04. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
discourse/app/controllers/admin/permalinks_controller.rb
2015-07-17 21:39:23 +05:30

35 lines
781 B
Ruby

class Admin::PermalinksController < Admin::AdminController
before_filter :fetch_permalink, only: [:destroy]
def index
url = params[:filter]
permalinks = Permalink.filter_by(url)
render_serialized(permalinks, PermalinkSerializer)
end
def create
params.require(:url)
params.require(:permalink_type)
params.require(:permalink_type_value)
permalink = Permalink.new(:url => params[:url], params[:permalink_type] => params[:permalink_type_value])
if permalink.save
render_serialized(permalink, PermalinkSerializer)
else
render_json_error(permalink)
end
end
def destroy
@permalink.destroy
render json: success_json
end
private
def fetch_permalink
@permalink = Permalink.find(params[:id])
end
end