Skip to content

Instantly share code, notes, and snippets.

@radar
Forked from anonymous/gist:727693
Created December 3, 2010 23:08
Show Gist options
  • Select an option

  • Save radar/727694 to your computer and use it in GitHub Desktop.

Select an option

Save radar/727694 to your computer and use it in GitHub Desktop.
== MODEL ==
// do a check here to verify the requested subdomain is available
def subdomain_is_unique
business = Business.where( "lower(subdomain) = ?", subdomain.downcase ).first
if !business.nil?
errors.add( :subdomain, 'is already in use' )
else
business = Business.new(:business_name => business_name, :subdomain => subdomain )
end
self.business_id = business.id
end
== CONTROLLER ==
def create
super
if // validations all pass let's create defaults
Business.create_defaults(business_id)
Location.create_defaults(business_id)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment