0
我正在請求來自不同Rails應用程序的任何用戶。我正在使用grape
寶石。以下代碼是請求的用戶信息發送控制器操作。Rails應用程序路由無法從Grape API訪問
,但遺憾的是,示值誤差:
NoMethodError (undefined method `profile_url' for #<Grape::Endpoint:0xdadef8c>):
問題是什麼?顯示網址的我的rake routes
確實存在。
module V1
class User < Grape::API
version 'v1', using: :path
format :json
prefix :api
resource :user do
desc "find any user"
params do
requires :email, type: String
requires :password, type: String
end
get :create do
user = User.find_by_email(params[:email])
if user.present?
if user.valid_password?(params[:password])
{user: user, profile_url: profile_url(user.profile)}
else
{:notice => "Invalid password for email: #{params[:email]}"}
end
else
{:notice => "No user found with email: #{params[:email]}"}
end
end
end
end
end
rake routes | grep profile
:
profiles GET /profiles(.:format) profiles#index
POST /profiles(.:format) profiles#create
new_profile GET /profiles/new(.:format) profiles#new
edit_profile GET /profiles/:id/edit(.:format) profiles#edit
profile GET /profiles/:id(.:format) profiles#show
PATCH /profiles/:id(.:format) profiles#update
PUT /profiles/:id(.:format) profiles#update
DELETE /profiles/:id(.:format) profiles#destroy
你可以分享你的'耙路線的結果| grep配置文件? – nayiaw