我正在尝试实施收集路线,但收到此错误
ActionController::RoutingError (No route matches [POST] "/api/users/editProfile"):
path/gems/actionpack-4.2.6/lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
path/gems/web-console-2.3.0/lib/web_console/middleware.rb:20:in `block in call'
path/gems/web-console-2.3.0/lib/web_console/middleware.rb:18:in `catch'
path/gems/web-console-2.3.0/lib/web_console/middleware.rb:18:in `call'
path/gems/actionpack-4.2.6/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
path/gems/railties-4.2.6/lib/rails/rack/logger.rb:38:in `call_app'
path/gems/railties-4.2.6/lib/rails/rack/logger.rb:20:in `block in call'
path/gems/activesupport-4.2.6/lib/active_support/tagged_logging.rb:68:in `block in tagged'
path/gems/activesupport-4.2.6/lib/active_support/tagged_logging.rb:26:in `tagged'
path/gems/activesupport-4.2.6/lib/active_support/tagged_logging.rb:68:in `tagged'
path/gems/railties-4.2.6/lib/rails/rack/logger.rb:20:in `call'
path/gems/actionpack-4.2.6/lib/action_dispatch/middleware/request_id.rb:21:in `call'
path/gems/rack-1.6.4/lib/rack/methodoverride.rb:22:in `call'
path/gems/rack-1.6.4/lib/rack/runtime.rb:18:in `call'
path/gems/activesupport-4.2.6/lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
path/gems/rack-1.6.4/lib/rack/lock.rb:17:in `call'
path/gems/actionpack-4.2.6/lib/action_dispatch/middleware/static.rb:120:in `call'
path/gems/rack-1.6.4/lib/rack/sendfile.rb:113:in `call'
path/gems/railties-4.2.6/lib/rails/engine.rb:518:in `call'
path/gems/railties-4.2.6/lib/rails/application.rb:165:in `call'
path/gems/rack-1.6.4/lib/rack/lock.rb:17:in `call'
path/gems/rack-1.6.4/lib/rack/content_length.rb:15:in `call'
path/gems/rack-1.6.4/lib/rack/handler/webrick.rb:88:in `service'
/usr/share/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/httpserver.rb:138:in `service'
/usr/share/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/httpserver.rb:94:in `run'
/usr/share/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/server.rb:294:in `block in start_thread'
Rendered path/gems/actionpack-4.2.6/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (1.8ms)
Rendered path/gems/actionpack-4.2.6/lib/action_dispatch/middleware/templates/routes/_route.html.erb (6.2ms)
Rendered path/gems/actionpack-4.2.6/lib/action_dispatch/middleware/templates/routes/_table.html.erb (1.2ms)
Rendered path/gems/actionpack-4.2.6/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (0.9ms)
Rendered path/gems/actionpack-4.2.6/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb within rescues/layout (62.4ms)
resources :users do
collection do
post '/users/editProfile' => 'users#update'
end
end
class Api::V1::UsersController < Api::V1::ApisController
skip_before_action :authenticate_user, :except => [:destroy]
before_action :set_user, only: [:show, :edit, :update, :destroy]
def update
@user.attributes = user_params
@user.skip_password_validation = true
if @user.save
render :json => {result: true,:object => @user}
else
render :json => {result: false,status: INVALID_CREDENTAILS_STATUS,:object => @user.errors.full_messages}
end
end
private
def user_params
params.require(:user).permit(:email,:password,:password_confirmation,:first_name,:last_name,:mobile_number,:landline_number,:office_number ,:profile )
end
end
答案 0 :(得分:0)
写一下 post&#39; / editProfile&#39; =&GT; &#39;#用户更新&#39; 代替 发布&#39; / users / editProfile&#39; =&GT; &#39;#用户更新&#39;