Skip to content

Instantly share code, notes, and snippets.

@m4tthumphrey
Created January 16, 2013 17:43
Show Gist options
  • Save m4tthumphrey/4549115 to your computer and use it in GitHub Desktop.
Save m4tthumphrey/4549115 to your computer and use it in GitHub Desktop.
class PermittedParams < Struct.new(:params, :user)
def topic
params.require(:topic).permit(*topic_attributes)
end
def topic_attributes
[:name].tap do |attributes|
attributes << :sticky if user && user.admin?
attributes << {posts_attributes: {:"0" => post_attributes}}
end
end
def post_attributes
[:content].tap do |attributes|
attributes << :inline_images if user && user.admin?
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment