Created
February 22, 2014 13:23
-
-
Save mikekreeki/9154756 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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