0

EDIT: All I need is render /devise/registrations/edit in /settings/password

To do that put this your view e.g. /settings/password

<%= render :template => 'devise/registrations/edit' %>

and This in SettingsHelper

def resource_name
  :user
end

def resource
  @resource = current_user || User.new
end

def devise_mapping
  @devise_mapping ||= Devise.mappings[:user]
end

def devise_error_messages!
  return "" if resource.errors.empty?

  messages = resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join
  sentence = I18n.t("errors.messages.not_saved",
                    :count => resource.errors.count,
                    :resource => resource_name)

  html = <<-HTML
          <div id='error'>
            <h2>{sentence}<h2>
            <p>#{messages}</p>

        </div>
  HTML

  html.html_safe
end

1 Answer 1

2

You can do the following:

 #routes.rb
 get 'settings/password' => 'users#password'

And then in your controller, create the action password:

#users_controller.rb
def password
  redirect_to :edit
end

If you are using Rails 3, you can simply do this:

 #routes.rb
 get 'settings/password' => redirect('users/edit')

Maybe this is what you are after?

 #routes.rb
 devise_for :users do
   get 'settings/password' => 'devise/registrations#edit'
 end
10
  • hmm, in this case I would go with 'user#edit' but I don't want a redirect, I just want /settings/password to stay in url. Kinda hidden alias if I can call it.
    – Flak
    Jan 24, 2012 at 1:19
  • If you want /settings/password to stay in the url and you want to call the action edit on users, what's the problem with doing get 'settings/password' => 'users#edit'?
    – Ashitaka
    Jan 24, 2012 at 1:27
  • well its not working doing that. github.com/plataformatec/devise/wiki/…
    – Flak
    Jan 24, 2012 at 1:49
  • Aah, I see, so you are using devise (guess I didn't notice the tag). Maybe you should edit your question and clarify a bit more what you want to do. You want to give a user the option of editing his account without having to input his password and the option of changing his password, is that it?
    – Ashitaka
    Jan 24, 2012 at 1:54
  • All I need is render /devise/registrations/edit in /settings/password so Users can change their password from there instead of /users/edit. when I render like : <%= render :template => 'devise/registrations/edit', :locals => { :resource => "user", :resource_name => "user" } %> I get undefined local variable or method `resource'
    – Flak
    Jan 24, 2012 at 2:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.