English 中文(简体)
铁路废墟中带有替代更新方法的错误
原标题:Routing error with alternative update method in ruby on rails

3.1.3

我试图指出我改换的正确途径——我的用户——控制器的密码方法。

I m 目前正出现这一错误:

Routing Error

No route matches {:action=>"change_password", :controller=>"users", :format=>#<User id: 1, email: "[email protected]", encrypted_password: "$2a$10$lgmrRTYFUUrWStLl1Y.Oo.LqQ2Ybxa29YkDFw61/KG9O...", password_salt: "$2a$10$lgmrRTYFUUrWStLl1Y.Oo.", username: "foobar", created_at: "2012-01-07 23:02:29", updated_at: "2012-01-13 11:16:45", password_reset_token: nil, password_reset_sent_at: "2012-01-08 12:23:30">}

用户——控制器:

def change_password
      @user = current_user
      @user_password_matches = User.authenticate(@user.email, params[:current_password])
      if @user_password_matches.update_attributes(params[:user])
        login @user
        format.js   { render :js => "window.location =  #{settings_account_path} " } 
        flash[:success] = "Password updated" 
      else
        format.js   { render :form_errors }

      end
    end

认为:

<%= form_for @user, :remote => true, :url => change_password_path(@user) do |f| %>
Current password: <%= password_field_tag :current_password, :placeholder => "Password"  %><br />
New password: <%= f.password_field :password, :placeholder => "Password"  %><br />
Confirm password: <%= f.password_field :password_confirmation, :placeholder => "Confirm Password"  %><br />
<%= f.submit  update  %>

路线:

resources :users do
  member do
    put :change_password
  end
end
  resources :users
  resources :sessions
  resources :passwords
  resources :profiles


  root :to                   => "users#new"
  match  success             => "users#success"
  match  login               => "sessions#new"
  match  logout              => "sessions#destroy"
  match  reset_password      => "passwords#new"
  match  setup_new_password  => "passwords#edit"
  match  settings , :to      => "users#settings"


  match "/settings/account", :to => "users#account"
  match "/settings/edit_profile", :to => "profiles#edit_profile"


  match  /:username , :controller =>  users , :action =>  show 

所有希望做的Im只有用户进入密码(现时为密码)才能成功地通过认证(我使用的相同方法在用户中记录密码,确认密码与存储在db中的密码相匹配),如果确实使用用户的密码,则更新db中的属性。

幼儿园

最佳回答

页: 1

http://www.un.org/Depts/DGACM/index_french.htm 此外,你不需要一条习俗路线,检查我对您先前问题的答复。

问题回答

暂无回答




相关问题
rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

Auth-code with A-Za-z0-9 to use in an URL parameter

As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

activerecord has_many :through find with one sql call

I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签