Skip to content

Instantly share code, notes, and snippets.

Created December 30, 2011 07:55
Show Gist options
  • Save anonymous/1538573 to your computer and use it in GitHub Desktop.
Save anonymous/1538573 to your computer and use it in GitHub Desktop.
<%= javascript_include_tag "myjs" %>
<style type="text/css">
#container{width:900px;}
</style>
<%= session[:signup_params]%>
<%= form_for @company do |f| %>
<div style = "padding:5px;text-align:right;width:75%;min-width:900px;height:500px;margin:auto;padding:0px;">
<div style = "margin:auto;">
<div style = "height:30px;width:895;padding:0px;"><div style = "height:30px;width:590px;text-align:left;font-size:25px;float:left;padding-left:10px;">Select Plan:</div><div style = "height:30px;width:300px;text-align:left;font-size:25px;float:left;">Create Account:</div></div>
<div style = "width:600px;height:100%;float:left;">
<div id = "signupplans" style = "float:right;">
<div id = "personal" class = "plantype">
<div class = "planname"><%= f.radio_button :company_type, "1" %>Personal</div>
<div class = "planprice" >Free</div>
<hr class = "divider"></hr>
<div>
<p class = "plandesc">Access/Modify Files from anywhere. Share files with others through customized emails.Files searchable by other users.</p>
</div>
<a href="/signup/personal"><img src = "/images/signupbig.png"></a>
</div>
<div id = "personal" class = "plantype">
<div class = "planname"><%= f.radio_button :company_type, "2" %>Executive</div>
<div class = "planprice">$20/Month</div>
<hr class = "divider"></hr>
<div>
<p class = "plandesc">Secure file storage and sharing. Full-text search of files and file versioning</p>
</div>
<% if signed_in? %>
<a href="/signup/executive"><img src = "/images/upgradebig.png"></a><% else %><a href="/signup/executive">
<img src = "/images/signupbig.png">
</a>
<% end %>
</div>
<div id = "personal" class = "plantype">
<div class = "planname" ><%= f.radio_button :company_type, "3" %>Business</div>
<div class = "planprice">$40/Month</div>
<hr class = "divider"></hr>
<div>
<p class = "plandesc">Customizeable and secure file storage and sharing. Multi-user capability and administration console.</p>
</div>
<% if signed_in? %>
<a href="/signup/business">
<img src = "/images/upgradebig.png">
</a>
<% else %>
<a href="/signup/business">
<img src = "/images/signupbig.png">
</a>
<% end %>
</div>
</div>
</div>
<!--<h2 style = "text-align:left;width:295px;float:right;height:20px;">Create Account</h2>-->
<div style = "width:290px;height:100%;float:left;padding-top:0px;padding-right:10px;">
<div style = "border: solid 1px #ccc;padding-right:5px;">
<!--<h2 style = "text-align:left;padding-bottom:15px;">Create Account</h2>-->
<%= f.fields_for :users do |builder| %>
<%= f.error_messages %>
<%= render "user_fields", :f => builder %>
<% end %>
<div id="storage" class="field">
<%= f.label :'Email Address', :class => 'signuplabel' %>
<%= f.select(:storage,[['5GB - Free', '1'],['15GB- $9.99', '2'],['25GB - $15.99','3']], :selected => '1') %>
</div>
<%= f.hidden_field :signup_step, :value => '1' %>
<div id ="signupsubmit"><%= f.submit "Submit"%></div><br />
</div>
</div>
</div>
</div>
<% end %>
<div class="field">
<%= f.label :Username, :class => 'signuplabel' %><span class = "asterisk">*</span> <%= f.text_field :username, :id => "username", :class => 'fright', :size => 20, :style => 'height:20px;' %>
</div>
<div class="field">
<%= f.label :Password, :class => 'signuplabel' %><span class = "asterisk">*</span> <%= f.password_field :password, :id => "password", :class => 'fright', :size => 20, :style => 'height:20px;' %>
</div>
<div class="field">
<%= f.label :'Confirm Pass', :class => 'signuplabel' %><span class = "asterisk">*</span> <%= f.password_field :password_confirmation, :id => "password_confirmation", :class => 'fright', :size => 20, :style => 'height:20px;' %>
</div>
<div class="field">
<%= f.label :Name, :class => 'signuplabel' %><span class = "asterisk">*</span> <%= f.text_field :name, :id => "name", :class => 'fright', :size => 20, :style => 'height:20px;' %>
</div>
<div class="field">
<%= f.label :'Email Address', :class => 'signuplabel' %><span class = "asterisk">*</span> <%= f.text_field :email_address, :id => "email_address", :class => 'fright', :size => 20, :style => 'height:20px;' %>
</div>
<div>
<%#= f.hidden_field :signup_step, :value => '3' %>
<%= f.hidden_field :acct_type, :value => '1' %>
</div>
def new
session[:signup_params] ||= {}
url = []
url << request.url.split('/')[3] << 'hello'
session[:steps] = url.last
@company = Company.new()
user = @company.users.build
@company.company_type = case params[:plantype]
when 'executive' then '2'
when 'business' then '3'
else
'1'
end
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @company }
end
end
def create
session[:signup_params].deep_merge!(params[:company]) if params[:company]
@company = Company.new(session[:signup_params])
respond_to do |format|
if @company.save
CompanyMailer.welcome_email(@company).deliver
format.html { redirect_to("/index", :notice => 'Account successfully created.') }
format.xml { render :xml => @company, :status => :created, :location => @company }
else
format.html { render :action => 'new' }
end
end
end
class Company < ActiveRecord::Base
attr_accessible :users_attributes, :storage, :company_type
attr_accessor :signup_step
###company validation
validates_presence_of :company_name, :message => "Company Name is required!", :unless => :company_type_is_one?
validates_length_of :company_name, :minimum => 4, :message => "Company Name must be at least 4 characters long!"
validates_format_of :company_name, :with => /^[a-zA-Z0-9\s_-]{4,}$/, :message => "Only letters, numbers, hyphens, and spaces are allowed!"
###phone number validation
validates_presence_of :phone, :message => "Phone Number is required!"
validates_format_of :phone, :with => /^([0-9]{3})( |-|.)([0-9]{3}( |-|.)[0-9]{4})(\s+|\s*[-\.x|X]{1}\s*\d{1,6})?$/, :message => "Invalid phone number"
### website validation
validates_format_of :website, :with => /^(https?\:\/\/)?[a-zA-Z0-9\-\.]+\.(tv|com|cc|org|net|mil|edu|TV|COM|CC|ORG|NET|MIL|EDU)$/, :message => "Invalid website", :allow_blank => true
###url validation
validates_presence_of :url, :message => "URL is required!"
validates_uniqueness_of :url, :message => "URL already exists, please choose another!"
validates_length_of :url, :minimum => 3, :message => "URL must be at least 3 characters long!"
validates_format_of :url, :with => /^[a-zA-Z0-9_-]{3,}$/, :message => "Only letters, numbers, hyphens, and underscores are allowed!"
has_many :users
has_many :uploads
has_many :paintings
accepts_nested_attributes_for :users
def company_type_is_one?
self.signup_step == 1
end
end
SyntaxError (/home/rhino/picturesque6/app/models/company.rb:24: syntax error, unexpected keyword_end):
app/controllers/companies_controller.rb:41:in `new'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment