Skip to content

Instantly share code, notes, and snippets.

@mikekreeki
Created February 22, 2014 13:23
Show Gist options
  • Save mikekreeki/9154756 to your computer and use it in GitHub Desktop.
Save mikekreeki/9154756 to your computer and use it in GitHub Desktop.
class PostsController < ApplicationController
respond_to :json # default to Active Model Serializers
def index
respond_with Post.all
end
def show
respond_with Post.find(params[:id])
end
def create
respond_with Post.create(post_params)
end
def update
respond_with Post.update(params[:id], post_params)
end
def destroy
respond_with Post.destroy(params[:id])
end
private
def post_params
params.require(:post).permit(:title, :intro, :extended, :published_at, :author) # only allow these for now
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment