0

I have a master admin who can create two different admins [property, content_contributor]. In the master admin's require params I have this

 class MasterAdmins::ContentContributorsController < MasterAdmins::MainController
....
params.require(:content_contributor).permit(:user_id, user_attributes: [:id, :activation_token, :email, :encrypted_password, :authentication_token, :sign_in_count]

and in master admins property I have this

 class MasterAdmins::PropertyAdminsController < MasterAdmins::MainController
 .....
 params.require(:property_admin).permit(user_attributes: [:id, :activation_token, :email, :encrypted_password, :authentication_token, :sign_in_count]

I am getting duplicate found in code climate. How can I avoid the user attribute duplication?

Richard Hamilton
  • 25,478
  • 10
  • 60
  • 87
Anbazhagan p
  • 943
  • 1
  • 14
  • 27
  • make a controller and inherit from it.. – argentum47 Apr 01 '15 at 15:07
  • for just one line params .require i need to create a controller? – Anbazhagan p Apr 01 '15 at 15:10
  • will you try please, it should work, – argentum47 Apr 01 '15 at 15:14
  • Can you help me with coding? Do i need to to write a method in mainController and then call it inside the params? – Anbazhagan p Apr 02 '15 at 02:01
  • check this.. https://github.com/argentum47/stekoverflu/blob/votes_and_ui/app/controllers/votes_controller.rb https://github.com/argentum47/stekoverflu/blob/votes_and_ui/app/controllers/answers_votes_controller.rb . only that, you will have the `def admin_params; params...` in one controller and then you can say `Admin.create(admins_param)` in either of your controller. make sure you don't call a private method by any object explicitly, even self.admin_params would be an error.. – argentum47 Apr 02 '15 at 04:43
  • When pasting code into SO, please try to make it so that horizontal scrolling isn't needed. I just can't read code that is one long line... by the time I scroll to the end, I forget what was at the beginning. – Wayne Conrad Apr 04 '15 at 17:08

0 Answers0