I currently have this as the Registration Controller for Devise
class RegistrationsController < Devise::RegistrationsController
protected
def after_update_path_for(resource)
edit_user_registration_path
end
end
I want to enter in certain fields (company_name, user_id that was
created) into a database called Company because I want to create
multiple users for each company.
Do you know how to write this in the Devise controller?
If you're talking about default attributes for your user, you could probably override the `build_resource` method, call super and do whatever you want with it, something like:
def build_resource(*args) resource = super resource.company_id = 1 # for instance resource end
On Sunday, February 12, 2012 at 9:05 PM, Bruce wrote: > I currently have this as the Registration Controller for Devise
> class RegistrationsController < Devise::RegistrationsController
> protected
> def after_update_path_for(resource) > edit_user_registration_path > end > end
> I want to enter in certain fields (company_name, user_id that was > created) into a database called Company because I want to create > multiple users for each company.
> Do you know how to write this in the Devise controller?
carlosantoniodasi...@gmail.com> wrote: > If you're talking about default attributes for your user, you could > probably override the `build_resource` method, call super and do whatever > you want with it, something like:
> def build_resource(*args) > resource = super > resource.company_id = 1 # for instance > resource > end
> -- > At. > Carlos Antonio
> On Sunday, February 12, 2012 at 9:05 PM, Bruce wrote:
> I currently have this as the Registration Controller for Devise
> class RegistrationsController < Devise::RegistrationsController
> protected
> def after_update_path_for(resource) > edit_user_registration_path > end > end
> I want to enter in certain fields (company_name, user_id that was > created) into a database called Company because I want to create > multiple users for each company.
> Do you know how to write this in the Devise controller?
Everything depends on what you want to achieve. For instance, ff you want to create a company together with the user, given user input, you should probably use nested attributes or something.
On Monday, February 13, 2012 at 3:24 AM, Bruce Ackerman wrote: > Hmm, so this is the best way to do an additional > @company = Company.new(params[:name blah]) > @company.save
> to the devise controller?
> On Sun, Feb 12, 2012 at 7:57 PM, Carlos Antonio da Silva <carlosantoniodasi...@gmail.com (mailto:carlosantoniodasi...@gmail.com)> wrote: > > If you're talking about default attributes for your user, you could probably override the `build_resource` method, call super and do whatever you want with it, something like:
> > def build_resource(*args) > > resource = super > > resource.company_id = 1 # for instance > > resource > > end
> > -- > > At. > > Carlos Antonio
> > On Sunday, February 12, 2012 at 9:05 PM, Bruce wrote:
> > > I currently have this as the Registration Controller for Devise
> > > class RegistrationsController < Devise::RegistrationsController
> > > protected
> > > def after_update_path_for(resource) > > > edit_user_registration_path > > > end > > > end
> > > I want to enter in certain fields (company_name, user_id that was > > > created) into a database called Company because I want to create > > > multiple users for each company.
> > > Do you know how to write this in the Devise controller?
carlosantoniodasi...@gmail.com> wrote: > Everything depends on what you want to achieve. For instance, ff you want > to create a company together with the user, given user input, you should > probably use nested attributes or something.
> -- > At. > Carlos Antonio
> On Monday, February 13, 2012 at 3:24 AM, Bruce Ackerman wrote:
> Hmm, so this is the best way to do an additional > @company = Company.new(params[:name blah]) > @company.save
> to the devise controller?
> On Sun, Feb 12, 2012 at 7:57 PM, Carlos Antonio da Silva < > carlosantoniodasi...@gmail.com> wrote:
> If you're talking about default attributes for your user, you could > probably override the `build_resource` method, call super and do whatever > you want with it, something like:
> def build_resource(*args) > resource = super > resource.company_id = 1 # for instance > resource > end
> -- > At. > Carlos Antonio
> On Sunday, February 12, 2012 at 9:05 PM, Bruce wrote:
> I currently have this as the Registration Controller for Devise
> class RegistrationsController < Devise::RegistrationsController
> protected
> def after_update_path_for(resource) > edit_user_registration_path > end > end
> I want to enter in certain fields (company_name, user_id that was > created) into a database called Company because I want to create > multiple users for each company.
> Do you know how to write this in the Devise controller?