Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

Just need some quick help with syntax

I'm using strong_parameters for Treebook like this

#Permit Additional Paramaters for sign_up
before_filter :configure_permitted_parameters, if: :devise_controller?
protected
  def configure_permitted_parameters
    devise_parameter_sanitizer.for(:sign_up) << :profile_name
    devise_parameter_sanitizer.for(:sign_up) << :first_name
    devise_parameter_sanitizer.for(:sign_up) << :last_name      
end

Is there a way to put those three lines as one line?

Cheers,

Tom

1 Answer

Nevermind, found it.

devise_parameter_sanitizer.for(:sign_up) << :first_name << :last_name << :profile_name

Alternatively,

devise_parameter_sanitizer.for(:sign_up) << [:first_name, :last_name, :profile_name]

works, but I think that's pushing a new array into an array so I think the top is better form yes? It's good enough for me anyhoo.