GithubHelp home page GithubHelp logo

Comments (11)

huoxito avatar huoxito commented on May 29, 2024 1

Hey @ayraju update to latest spree_auth_devise 2-1-stable, as of 862921a you should be able to set those params with this code in your spree.rb initializer:

Spree::PermittedAttributes.user_attributes.push :f_name, :l_name

let us know if that goes wrong. And make sure you get it that every user can update those params. You shouldn't use that approach for params only allowed by certain kinds of users.

from spree_auth_devise.

ayraju avatar ayraju commented on May 29, 2024

I want to upgrade my application spree2.0 customizations to spree-2.1

My old customization: spree-2.0

Spree::User.class_eval do
attr_accessible :f_name, :l_name :gender
validates :f_name, :presence => true, :length => {:maximum => 25}
validates :l_name, :presence => true, :length => {:maximum => 20}
end

New work with strong parameters: spree-2.1

module Spree
UserRegistrationsController.class_eval do
private
def spree_user_params
params.require(:spree_user).permit(:f_name, :l_name)
end
end
end

Even though its not working as it got rollback..

Please any idea for adding new fields.

from spree_auth_devise.

kitwalker12 avatar kitwalker12 commented on May 29, 2024

@ayraju your second method works for me in Spree 2.1.2 & spree_auth_devise using 2-1-stable. Maybe you need to include the rest of the User fields as well as you're overwriting, not extending, the spree_user_params method. I have the following code in my /app/controllers/spree/user_registrations_controller_decorator.rb

Spree::UserRegistrationsController.class_eval do
  private
    def spree_user_params
      params.require(:spree_user).permit(:first_name, :last_name, :email, :password, :password_confirmation)
    end
end

from spree_auth_devise.

ayraju avatar ayraju commented on May 29, 2024

Hi @huoxito

Its working from front end fine i.e registration but not from admin interface as admin will add user.
It will work I hope If you do same change in spree::admin::userscontroller.

Hi @kitwalker12

yes, that will work as I tried earlier as overwritten. same we need to do from admin also.

Guys, please check my comments and let me know your thoughts.

from spree_auth_devise.

huoxito avatar huoxito commented on May 29, 2024

@ayraju It's done see 4220432. Thanks for pointing it out!

from spree_auth_devise.

chandasandeep avatar chandasandeep commented on May 29, 2024

@ayraju Can you share the deface code ? I am trying to add a similar field to the user registration form. But keep getting a no method error.

from spree_auth_devise.

ayraju avatar ayraju commented on May 29, 2024

@CapedCrusader

You can add whatever fields by using this line on initializers/spree.rb for User.

Spree::PermittedAttributes.user_attributes.push :f_name, :l_name

from spree_auth_devise.

chandasandeep avatar chandasandeep commented on May 29, 2024

@ayraju Do we need to perform any migrations after adding this line to initializers/spree.rb ?

Snapshot of my initializers/spree.rb

Spree.config do |config|
config.site_name = "Ecommerce demo"
end

Spree.user_class = "Spree::User"

Spree::PermittedAttributes.user_attributes.push :phone_number

from spree_auth_devise.

huoxito avatar huoxito commented on May 29, 2024

@CapedCrusader make sure you running on latest spree_auth_devise 2-1-stable

from spree_auth_devise.

chandasandeep avatar chandasandeep commented on May 29, 2024

@huoxito Thanks,working now ! Updated to spree_auth_devise 2-1-stable

from spree_auth_devise.

mvidaurre avatar mvidaurre commented on May 29, 2024

I had not find the way to use nested_forms, for example: biil_address to fill that at signup. Someone has any idea if that is possible using this, or I should implement this functionality. Thanks

from spree_auth_devise.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.