user470763
user470763

Reputation:

Creating Devise user via JSON

I'm successfully able to create a new devise user via JSON. I get a message saying it successfully saved however the user doesn't appear in the database and I can't login with the account.

    def create
        respond_with Actor.new(actor_params)
    end

I get a 201 when I call this suggesting it works but as I said it isn't really saving. What's the issue?rails

Upvotes: 0

Views: 54

Answers (1)

Robin
Robin

Reputation: 8498

You only create a new instance of your model Actor, but you don't persist it to the database.

def create
  @actor = Actor.new(actor_params)

  if @actor.save
    respond_with @actor
  else
    # return an error
  end
end

The example above, will persist your record, if there is no validation or constraint error.

Upvotes: 1

Related Questions