Accessing Custom Parameters when using Devise and Rails 4

前端 未结 1 1424
-上瘾入骨i
-上瘾入骨i 2021-01-07 11:50

I am learning rails using the teamtreehouse tutorial. The tutorial uses 3.1 but I am trying to learn 4.0, and as a result I have run into a difficulty presumably because ra

相关标签:
1条回答
  • 2021-01-07 12:22

    welcome on board. :) Rails is just amazing and you will really enjoy this journey. :)

    I think, here you will find your answer: https://github.com/plataformatec/devise/tree/rails4#strong-parameters

    Based on above link, I think you should insert something like this in your ApplicationController:

    class ApplicationController < ActionController::Base
      before_filter :configure_permitted_parameters, if: :devise_controller?
    
      protected
    
      def configure_permitted_parameters
        devise_parameter_sanitizer.for(:user) { |u| u.permit(:profile_name) }
      end
    end
    

    And I already suggested in a previous question... Strong parameters with Rails and Devise

    ...that you can create your own controller which could extend devise own controller. There is a gist for that: https://gist.github.com/bluemont/e304e65e7e15d77d3cb9

    A little bit more details in Devise doc: https://github.com/plataformatec/devise/tree/rails4#configuring-controllers

    Hope it could help, and let me know what happened.

    0 讨论(0)
提交回复
热议问题