Ruby on rails用户注册使用rest API调用和Devise [英] Ruby on rails User registration using rest API call and Devise

查看:125
本文介绍了Ruby on rails用户注册使用rest API调用和Devise的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以指导我如何在轨道上的ruby中从移动设备(rest API)注册用户。我正在使用Devise with Rails 3.0。



它给我以下错误



Devise中的NameError: :CustomRegistrationsController#create

解决方案

我已经用以下方法覆盖了devise注册控制器的功能。

  def create 
respond_to do | format |
format.html {
super
}
format.json {
build_resource
如果resource.save
呈现:status => 200,json =>资源
else
呈现:json => resource.errors,:status => :unprocessable_entity
end
}
end
end

这解决了问题,我已经添加了

  skip_before_filter:verify_authenticity_token,:only => :创建

以避免真实性检查。


Can anyone guide me how to register a user from mobile device (rest API) in ruby on rails. I'm using Devise with Rails 3.0.

it is giving me this following error

NameError in Devise::CustomRegistrationsController#create

解决方案

I've override the functionality of devise registration controller with the following.

def create
  respond_to do |format|  
    format.html { 
      super 
    }
    format.json {
      build_resource
      if resource.save
         render :status => 200, :json => resource
      else
        render :json => resource.errors, :status => :unprocessable_entity
      end
    }
  end
 end

this solved the problem and I've added

    skip_before_filter :verify_authenticity_token, :only => :create

to avoid authenticity check.

这篇关于Ruby on rails用户注册使用rest API调用和Devise的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆