Created
January 16, 2013 17:43
-
-
Save m4tthumphrey/4549115 to your computer and use it in GitHub Desktop.
This file contains 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 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