Skip to content

Instantly share code, notes, and snippets.

@brianp
Forked from napcs/gist:2049862
Last active December 14, 2015 22:18
Show Gist options
  • Select an option

  • Save brianp/5157252 to your computer and use it in GitHub Desktop.

Select an option

Save brianp/5157252 to your computer and use it in GitHub Desktop.
class PostsController < ActionController::Base
def create
Post.create(post_params)
end
def update
Post.find(params[:id]).update_attributes!(post_params)
end
private
def post_params
params[:post].slice(Post.web_accessible)
end
end
class Post
def self.web_accessible
[:title, :body]
end
def self.api_accessible
[:title]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment