-
-
Save universal/dc1330a7b1a5cfc2dda5 to your computer and use it in GitHub Desktop.
View Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= form_for(resource, url: registration_path(resource_name), method: :post) do |f| %> | |
<%= f.fields_for :contacts do |contact_fields| %> | |
Nome: <%= contact_fields.text_field :name %> | |
<% end %> | |
<div class="register-buttons"> | |
<%= f.submit "Finish", class: "button button-primary", data: { disable_with: "Finish" } %> | |
</div> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Registration | |
include ActiveModel::Model | |
attr_accessor :contacts | |
def initialize(customer, params = {}) | |
@contacts = [Contact.new, Contact.new] | |
@customer = customer | |
super(params) | |
end | |
def contacts_attributes=(attributes) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RegistrationsController < Devise::RegistrationsController | |
prepend_before_filter :authenticate_scope!, only: [:edit, :update, :destroy, :success_sign_up] | |
def new; end | |
def create | |
@resource = Registration.new(customer, params) | |
end | |
def resource | |
@resource ||= Registration.new(customer) | |
end | |
def success_sign_up; end | |
# overriding sign up to work with form object instead directly with model | |
def sign_up(resource_name, resource) | |
sign_in(resource_name, resource.customer) | |
end | |
private | |
def customer | |
current_customer || Customer.new | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment