Develop an undefined method `users_url 'for # <Devise :: RegistrationsController: 0x00000003b299b0>
I get this error when registering a development:
undefined method `users_url' for #<Devise::RegistrationsController:0x00000003b299b0>
With Omniauth facebook, login, everything works fine.
class User < ActiveRecord::Base
has_one :profile, :dependent => :destroy
after_save :myprofile
def myprofile
if self.profile
else
Profile.create(user_id: self.id, user_name: self.name)
end
end
end
class Profile < ActiveRecord::Base
belongs_to :user
end
What could be the solution for this work with registration?
Important: it works with omniauth facebook , but it does not work with development .
Edit: I get this error using Profile.create! Method:
NoMethodError - undefined method `users_url' for #<Devise::RegistrationsController:0x00000005946e20>:
actionpack (3.2.13) lib/action_dispatch/routing/polymorphic_routes.rb:129:in `polymorphic_url'
actionpack (3.2.13) lib/action_dispatch/routing/url_for.rb:150:in `url_for'
actionpack (3.2.13) lib/action_controller/metal/redirecting.rb:105:in `_compute_redirect_to_location'
actionpack (3.2.13) lib/action_controller/metal/redirecting.rb:74:in `redirect_to'
actionpack (3.2.13) lib/action_controller/metal/flash.rb:25:in `redirect_to'
Edit_2: Github repo: https://github.com/gwuix2/anabol
Github problem:
0
2 answers
, Profile.create(user_id: self.id, user_name: self.name), . has_one, build_resource self after_create:
# app/models/user.rb
class User < ActiveRecord::Base
has_one :profile, :dependent => :destroy
after_create :myprofile
def myprofile
profile = Profile.create!(user_id: self.id, user_name: self.name) # `.create!` will throw an error if this fails, so it good for debugging
self.profile = profile
end
end
0