1

这是我的路线文件:

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

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

这是 rake 路由的输出:

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"}
4

2 回答 2

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 ?

于 2012-10-31T01:36:52.687 回答
0

您的路线是 POST,但您在表单中的方法是 PUT。

于 2012-06-21T20:54:35.660 回答