mercredi 13 avril 2016

Including a given user in Devise sing_up form

I'm getting a few fields of an oauth from Twitter or Facebook, if uid is persisted I'm logging in my app. But, I wanna redirect to register form with that user prebuilt.

It means,

I receive from Twitter:

{nickname: foo,
description: bar,
email: foo@bar.com
...
}

then I'm building an user:

User.new{nickname: foo, description: bar, email: foo@bar.com}

I want too render registrations/new with this fields filled, passing this @user as parameter to the view.

Too, this user have a relation one-to-one to profile any field filled with Auth. And a model Identity one to one which contains uid, provider fields. Filled with oauth.

The view receive this params... (resource, resource_name, devise_mappings, ...)

<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
  <%= devise_error_messages! %>

  <div class="field">
    <%= f.label :email %>

Any suggestion to do this?

I have to edit to say "Sorry for my english"

Aucun commentaire:

Enregistrer un commentaire