Created
September 15, 2011 00:47
-
-
Save masonforest/1218245 to your computer and use it in GitHub Desktop.
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 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 | |
@[email protected](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