Sha256: 132b32eeabe8e27542776a9ababae039a23c270adc068acdacb3cd5f5cbaa61b

Contents?: true

Size: 1.74 KB

Versions: 15

Compression:

Stored size: 1.74 KB

Contents

class SitesController < InheritedResources::Base
  load_and_authorize_resource
  
  def new
    @files = Dir.open("public/stylesheets/ice")
    @site=site
    if(!@site)
      @site = Site.new

      respond_to do |format|
        format.html # new.html.erb
        format.xml  { render :xml => @site }
      end
    else
      flash[:notice]="el sitio ya fue creado"
      
    end
  end

  # GET /sites/1/edit
  def edit
    if site
      @site = site
      @files = Dir.open("public/stylesheets/ice")
    else
      redirect_to({:action=>new})
    end
  end

  # POST /sites
  # POST /sites.xml
  def create    
    @site = Site.new(params[:site])
    respond_to do |format|
      if @site.save
        flash[:notice] = 'El sitio fue creado'
        format.html { redirect_to(:controller=>"users",:action=>'sign_up') }
        format.xml  { render :xml => @site, :status => :created, :location => @site }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @site.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /sites/1
  # PUT /sites/1.xml
  def update
    @site = Site.find(params[:id])
       
    respond_to do |format|
      if @site.update_attributes(params[:site])
        files = Dir.open("public/stylesheets/ice/#{@site.style}/ice")
        FileUtils.cp_r files ,"app/views/layouts/ice/#{@site.style}"
        flash[:notice] = 'Site was successfully updated.'
        format.html { redirect_to(@site) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @site.errors, :status => :unprocessable_entity }
      end
    end
  end
  
  def destroy
    @site = Site.last
    @site.destroy
    redirect_to(@site)
  end
end

Version data entries

15 entries across 8 versions & 1 rubygems

Version Path
squeezer-0.2.1 lib/generators/squeezer/templates/app/controllers/sites_controller.rb
squeezer-0.2.1 app/controllers/sites_controller.rb
squeezer-0.2.0 lib/generators/squeezer/templates/app/controllers/sites_controller.rb
squeezer-0.2.0 app/controllers/sites_controller.rb
squeezer-0.1.11 app/controllers/sites_controller.rb
squeezer-0.1.11 lib/generators/squeezer/templates/app/controllers/sites_controller.rb
squeezer-0.1.7 lib/generators/squeezer/templates/app/controllers/sites_controller.rb
squeezer-0.1.7 app/controllers/sites_controller.rb
squeezer-0.1.6 app/controllers/sites_controller.rb
squeezer-0.1.6 lib/generators/squeezer/templates/app/controllers/sites_controller.rb
squeezer-0.1.5 lib/generators/squeezer/templates/app/controllers/sites_controller.rb
squeezer-0.1.5 app/controllers/sites_controller.rb
squeezer-0.1.4 lib/generators/squeezer/templates/app/controllers/sites_controller.rb
squeezer-0.1.4 app/controllers/sites_controller.rb
squeezer-0.1.3 lib/app/controllers/sites_controller.rb