Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby on rails User registration using rest API call and Devise

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

like image 354
user561577 Avatar asked Dec 21 '22 04:12

user561577


1 Answers

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.

like image 119
user561577 Avatar answered Jan 05 '23 00:01

user561577