Skip to content

Instantly share code, notes, and snippets.

@coderforhire
Created April 2, 2013 16:49
Show Gist options
  • Save coderforhire/5293867 to your computer and use it in GitHub Desktop.
Save coderforhire/5293867 to your computer and use it in GitHub Desktop.
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => {:class => "form"}) do |f| %>
<% @user.domains.build %>
<%= devise_error_messages! %>
<%= f.email_field :email, :autofocus => true, :placeholder => "Email" %></br>
<%= f.password_field :password, :placeholder => "Password" %>
<%= f.password_field :password_confirmation, :placeholder => "Password again, please." %>
<%= f.fields_for :domains do |domain_form| %>
<%= domain_form.text_field :domain_name, :placeholder => "Domain Name" %>
<%= domain_form.text_field :domain_price, :placeholder => "Price (USD)" %>
<% end %>
<div><%= f.submit "Sign up", :class => " span3 btn btn-block btn-large" %></div>
<% end %>
~
class Domain < ActiveRecord::Base
require "addressable/uri"
@@heroku = Heroku::API.new(:username => USER, :password => PASS)
belongs_to :user
attr_accessible :name, :price, :user_id
def add_user_domain(domain)
www_domain = 'www.' + domain
@@heroku.post_domain('namesushi', domain)
@@heroku.post_domain('namesushi', www_domain)
end
end
~
~
~
<%= render 'devise/registrations/form' %>
class User < ActiveRecord::Base
has_many :domains
accepts_nested_attributes_for :domains
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me, :domains_attributes
end
~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment