reusability of strong_parameters

Hi there!

I’ve got code duplication using strong_parameters:

class PeopleController < ApplicationController


def person_params

  params.permit(:name, pets: [ :name, :age ])



Please post these kinds of questions to rubyonrails-talk, this list is
for discussions about the framework itself, not how to use it.

Like Steve said, if you want to talk more about it, use:!forum/rubyonrails-talk or StackOverflow is very responsive (just tag it properly and ask answerable questions).

But the two answers off the top of my head are using a module, and because concerns are not just something used throughout Rails code and in gems, but becoming a first-class citizen in Rails, read:
shared behavior in controllers could go into:
but you can just stick it anywhere in the path corresponding to the concern’s namespace and it would get autoloaded.

or as of this past weekend you could use the permitters gem:

but for vanilla Strong Parameters, module include is good way, and a concern may as well be the right way (depending on whether you are ok with the minor overhead in not using Ruby directly).

Mostly just using this as an excuse to post links, like usual. Will lay off now…