35698

Send Password for devise in Ruby on Rails

Question:

Hi i have an app on Ruby on Rails..

This is the GEMs im using. GEMFILE

gem 'rails', '3.2.8' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' #gem 'pg' gem 'mysql2' gem 'json' # Gems used only for assets and not required # in production environments by default. group :assets do gem 'sass-rails', '~> 3.2.3' gem 'coffee-rails', '~> 3.2.1' # See https://github.com/sstephenson/execjs#readme for more supported runtimes # gem 'therubyracer', :platforms => :ruby gem 'uglifier', '>= 1.0.3' end gem 'jquery-rails' group :test, :development do gem "rspec-rails" gem "shoulda" #gem "factory_girl_rails" end gem 'simple_form' gem "nested_form" gem 'wicked' gem "paperclip", "~> 3.0" gem 'ruby-units' # To use ActiveModel has_secure_password # gem 'bcrypt-ruby', '~> 3.0.0' # To use Jbuilder templates for JSON # gem 'jbuilder' # Use unicorn as the app server # gem 'unicorn' # Deploy with Capistrano # gem 'capistrano' # To use debugger # gem 'ruby-debug' #gem 'therubyracer' #gem 'less-rails' gem 'devise' gem 'globalize3' gem 'cancan'

Ok then in the models , in user.rb i got this

class User < ActiveRecord::Base # Include default devise modules. Others available are: # :token_authenticatable, :confirmable, # :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable has_and_belongs_to_many :roles has_one :player has_many :payment_notifications attr_accessible :email, :password, :password_confirmation, :remember_me, :user_type, :purchased_at validates :email, :presence => true after_create :is_a_player? def role?(role) return !!self.roles.find_by_name(role.to_s) end def is_a_player? if user_type == 'player' || user_type == 'coach' self.create_player(:active => false) self.roles << Role.find_by_name(:player) elsif user_type == 'elite' self.roles << Role.find_by_name(:elite) end end #private def paypal_url(return_url) values = { :business => 'mm@hotmail.com', :cmd => '_cart', :upload => 1, :return => return_url, #:invoice => 13, #id, #:notify_url => notify_url, :amount_1 => '100', :item_name_1 => 'Suscripcion a Myr', :item_number_1 => '1', :quantity_1 => '1' } "https://www.sandbox.paypal.com/cgi-bin/webscr?" + values.to_query end def purchase_defeated? t = Time.now - purchased_at mm, ss = t.divmod(60) hh, mm = mm.divmod(60) dd, hh = hh.divmod(24) dd > 180 ? true : false end end

I was looking for documentation for writing the send password (if forgot) but i found this <a href="https://stackoverflow.com/questions/6928461/devise-allowing-users-to-change-passwords" rel="nofollow">Devise, allowing users to change passwords</a>

When i insert this link on the View where the login is

<%= link_to 'Change Password', edit_user_registration_path %>

Im just redirected to the same page.. how can i make this view?

How can i define the path to this view.. cant write this :(

UPDATE:

In controllers/admin/user_controller i found this

def update @user = User.find(params[:id]) params[:user].delete(:password) if params[:user][:password].blank? params[:user].delete(:password_confirmation) if params[:user][:password].blank? and params[:user][:password_confirmation].blank? if @user.update_attributes(params[:user]) flash[:notice] = "Successfully updated User." redirect_to users_path else render :action => 'edit' end end

There is a view also with the form

<%= t('generales.edit_user') %>

<%= render 'form' %>

Change my question.. how can i move this from admin to public?

do i just have to copy that part of controller .. and insert the link in the view?

Answer1:

edit_user_registration_path is not for forgot password path

See <a href="https://github.com/plataformatec/devise/blob/master/app/views/devise/shared/_links.erb" rel="nofollow">Devise shared link</a>

You could include this link into your login form

<%= link_to "Forgot your password?", new_password_path(resource_name) %>

Recommend

  • Can't generate cancan:ability
  • Apache Camel inOut routes, out exchange marshaling/unmarshaling with jaxb
  • es6 Javascript class using this inside a callback [duplicate]
  • How to change a react state immediately by setTimeout after setState?
  • Cancan + Devise rescue_from not catching exception
  • loading backbone.js resources based on authentication
  • mod_perl.so for apache 2.4 required by bugzilla
  • Devise + Omniauth Facebook redirecting to signup
  • can i initialize an array outside the method just like we initialize a member/field variable
  • Ripple - Uncaught Error: Load timeout for modules: app http://requirejs.org/docs/errors.html#timeout
  • Firefox extension include script in main.js file
  • Formatting in NetBeans: CSS specific
  • Maven - which projects or techologies you are using it for?
  • “Not a git repository: ” Error when trying to add RestKit to my repository
  • Comparing floating point numbers with numpy and scipy
  • Appium Error: Could not get Xcode version
  • C++ face detection/recognition implementations
  • Amazon ec2 linux Imagemagick issues
  • how to overcome building error when I'm using bcp to export boost thread?
  • Wait for angular to finish updating the DOM
  • Redirect to trailng slash (htaccess)
  • Rails 3.2 from SQLite locally to Postgres on Heroku
  • python - calculate orthographic similarity between words of a list
  • what is the purpose of “export as namespace foo”?
  • Why are YouTube videos using 'youtube.com/v' not loading
  • Combining two different ActiveRecord collections into one
  • Could not find rake using whenever rails
  • Sails.js/waterline: Executing waterline queries in toJSON function of a model?
  • WinForms: two way TextBox problem
  • Can I make an Android app that runs a web view in Chrome 39?
  • InvalidAuthenticityToken between subdomains when logging in with Rails app
  • KeystoneJS: Relationships in Admin UI not updating
  • Turn off referential integrity in Derby? is it possible?
  • Authorize attributes not working in MVC 4
  • Busy indicator not showing up in wpf window [duplicate]
  • Observable and ngFor in Angular 2
  • UserPrincipal.Current returns apppool on IIS
  • Python/Django TangoWithDjango Models and Databases
  • java string with new operator and a literal
  • Net Present Value in Excel for Grouped Recurring CF