Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to expose resource in devise to another controller?

Im trying to render the default devise edit registrations view in a modal. The modal is being called from another controller.. Home_controller in this case.

I have <%= render :template, 'devise/registrations/edit' %> in my modal tag and it is being called when the launch modal button is clicked but rails is through me a undefined variable method in regards to devises use of resource. I know resource is just a user object but the home conroller does not know how to resolve this, i thought the render template method resolves this letting rails use the devise registrations controller.

Any ideas? Im really eanting to keep the deafault devise controller to simplify future features? How does one call a view from a different controller in one controller allowing thuse of all the actions in the called controller being available.

like image 574
TheIrishGuy Avatar asked Jan 17 '23 18:01

TheIrishGuy


1 Answers

Try adding this to application_helper.rb (from The Devise Wiki)

  def resource_name
    :user
  end

  def resource
    @resource ||= User.new
  end

  def devise_mapping
    @devise_mapping ||= Devise.mappings[:user]
  end
like image 168
Erik Petersen Avatar answered Jan 30 '23 01:01

Erik Petersen