我已经设计了身份验证,并且当我将用户创建为
curl -H 'Content-Type: application/json' -H 'Accept: application/json' -X POST htt://localhost:3000/users.json -d "{'user' : { 'username' : 'sample @example.com', 'password' : 'password', 'password_confirmation' : 'password' }}"
上述请求的响应是
{"user":{"authentication_token":"uwAqF4SG8kPirxWN35yp", "username":"sample@example.com"}}
但我希望得到回应
{"New user created successfully"}
我怎样才能改变以获得所需的响应?提前致谢。
更新
注册控制器创建方法如下,但我怎么能像你说的那样做
build_resource
if resource.save
if resource.active_for_authentication?
set_flash_message :notice, :signed_up if is_navigational_format?
sign_in(resource_name, resource)
respond_with resource, :location => after_sign_up_path_for(resource)
else
set_flash_message :notice, :inactive_signed_up, :reason => inactive_reason(resource) if is_navigational_format?
expire_session_data_after_sign_in!
respond_with resource, :location => after_inactive_sign_up_path_for(resource)
end
else
clean_up_passwords(resource)
respond_with_navigational(resource) { render_with_scope :new }
end