Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save speed-of-light/37b2fff2acd1ff5d52d5 to your computer and use it in GitHub Desktop.

Select an option

Save speed-of-light/37b2fff2acd1ff5d52d5 to your computer and use it in GitHub Desktop.
module Api
module V0
class LinksController < ApplicationController
# THIS
before_action :set_headers
def show
@link = Link.find(params[:id])
render json: @link
end
private
def link_params
params.require(:status).permit(:title, :href, :comment)
end
# THIS
def set_headers
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Allow-Methods'] = 'POST, PUT, DELETE, GET, OPTIONS'
headers['Access-Control-Request-Method'] = '*'
headers['Access-Control-Allow-Headers'] = 'Origin, X-Requested-With, Content-Type, Accept, Authorization'
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment