Skip to content

Instantly share code, notes, and snippets.

@masonforest
Created September 15, 2011 00:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masonforest/1218245 to your computer and use it in GitHub Desktop.
Save masonforest/1218245 to your computer and use it in GitHub Desktop.
class SitesController < ApplicationController
before_filter :authenticate_user, :except => "show"
def new
@site = Site.new
@site.domain = Domain.new
end
def activate
@site = Site.find(params[:id])
flash[:message] = render_to_string :partial=>"sites/welcome_message"
redirect_to sites_path
end
def show
@site = Site.find_by_domain(request.host)
if @site then
@output=@site.render(params[:path])
render :text => @output, :content_type => "text/html"
else
render "missing", status => 404
end
end
def create
params[:site][:user_id]=current_user.id
@site = Site.new(params[:site])
if @site.save
if @site.domain.tld == "kissr.co"
flash[:message] = render_to_string :partial=>"sites/welcome_message"
redirect_to '/sites'
else
redirect_to "https://kissr-test.recurly.com/subscribe/domain_preregistered/#{@site.id}?first_name=#{@site.user.first_name}&last_name=#{@site.user.last_name}"
end
else
render 'new'
end
end
def index
@sites = Site.where(:user_id=>current_user)
end
def destroy
@site = Site.find(params[:id])
flash[:message]="Deleted #{@site.domain}"
@site.destroy
redirect_to "/sites"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment