所以我有接受JSON請求軌服務器。我打算將它用作我的iPhone應用程序的服務器。我得到這個錯誤:缺少的部分用戶/用戶
Missing partial users/user with {:locale=>[:en], :formats=>[:json], :handlers=>[:erb, :builder, :coffee]}. Searched in: * "/Users/chalamphongpandey/rails_projects/comboo/app/views" * "/Users/chalamphongpandey/.rvm/gems/[email protected]/gems/devise-2.2.3/app/views"
我不明白缺少部分是因爲我沒有渲染任何視圖。所有創建操作(在我已配置爲sign_up的路由中)的操作是接受諸如用戶名,密碼,名稱等信息,創建用戶併發回確認信息(json格式)
我發送的網址是
http://localhost:3000/sign_up.json?username=chalami&password=chalami&name=chalami&[email protected]
我通過瀏覽器發送的URL,而不是通過應用程序發送的。我想先通過瀏覽器測試它。 我的代碼是
class UsersController < ApplicationController
respond_to :json
def create
@user = User.new(params[:user])
if @user.save
render :json => {:status => "200", :message => "Signed up successfully"}
else
render :json => {:status => "400", :message => "Failed"}
end
end
end
爲什麼我需要一個看法?我想從控制器接受一個json請求並呈現一個json響應,因此擴展名爲.json而不是.html,或者我錯過了什麼? – nupac
好的,告訴我你的'respond_to | format |'塊在哪裏? – David
我是否需要如果我不在乎渲染其他格式? – nupac