2012-06-04 75 views
1

这里是我的路线文件:没有路由的错误,但在耙路线的路线

devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" } 

    resources :users do 
    post 'update_and_sign_in', :on => :member 
    end 

这里是耙路线的输出:

update_and_sign_in_user POST /users/:id/update_and_sign_in(.:format) users#update_and_sign_in 
        users GET /users(.:format)      users#index 
         POST /users(.:format)      users#create 
       new_user GET /users/new(.:format)     users#new 
       edit_user GET /users/:id/edit(.:format)    users#edit 
        user GET /users/:id(.:format)     users#show 
         PUT /users/:id(.:format)     users#update 
         DELETE /users/:id(.:format)     users#destroy 

这里是控制器:

def update_and_sign_in 
    @user = User.find(params[:id]) 
    if @user.update_attributes(params[:user]) 
     redirect_to root_path, :notice => "You have successfully signed up" 
    else 
     render 'get_email' 
    end 
    end 

这里是表格:

=form_for(@user,:url => update_and_sign_in_user,:method => "put", :html => {:class => 'well'}) do |f| 

我得到这个错误,我想不通为什么或如何解决它:

No route matches {:action=>"update_and_sign_in", :controller=>"users"} 

回答

0

您的路线是一个职位,但你的形式方法PUT。

0

只是为了澄清:哪个控制器是:

def update_and_sign_in 
     @user = User.find(params[:id]) 
     if @user.update_attributes(params[:user]) 
     redirect_to root_path, :notice => "You have successfully signed up" 
     else 
     render 'get_email' 
     end 
    end 

上? UsersController或Users :: OmniauthCallbacksController?

相关问题