Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use email address as a parameter in a rails PUT request?

I have configured a route in config.rb

resources :password

When the parameter not an email address, it is working fine.

When the parameter is an email address it will show me the error:

Started PUT "/password/[email protected]" for 127.0.0.1 at 2012-02-22 17:04:17 +0800

ActionController::RoutingError (No route matches [PUT] "/password/[email protected]"):

UPDATE1

this is my password controller

  def update
    return_info = User.change_password(params[:id],params[:old],params[:newpw],params[:newpw2])

    respond_to do |format|
      format.json { render :json => {:info => t(return_info)} }
    end

  end

Thank you.

like image 461
yiqun Avatar asked Feb 22 '12 09:02

yiqun


1 Answers

if you use custom string instead of id try

resources :password, :constraints => { :id => /.*/ }
like image 189
Fivell Avatar answered Oct 28 '22 19:10

Fivell