TheIrishGuy
TheIrishGuy

Reputation: 2573

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.

Upvotes: 4

Views: 2992

Answers (1)

Erik Petersen
Erik Petersen

Reputation: 2357

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

Upvotes: 10

Related Questions