Sha256: 6d86642c191aacb6faef703872183a8b06530f2fd0ba21028c2e4d02cbb01370

Contents?: true

Size: 1.45 KB

Versions: 3

Compression:

Stored size: 1.45 KB

Contents

require_dependency "lit/application_controller"

module Lit
  class SourcesController < ApplicationController
    def index
      @sources = Source.all
    end

    def show
      @source = Source.find(params[:id])
    end

    def new
      @source = Source.new
    end

    def edit
      @source = Source.find(params[:id])
    end

    def synchronize
      @source = Source.find(params[:id])
      @source.synchronize
      redirect_to lit.source_incomming_localizations_path(@source)
    end

    def touch
      @source = Source.find(params[:id])
      @source.touch_last_updated_at!
      redirect_to request.env["HTTP_REFERER"].present? ? :back : @source
    end

    def create
      @source = Source.new(clear_params)
      if @source.save
        redirect_to @source, :notice => 'Source was successfully created.'
      else
        render :action => "new"
      end
    end

    def update
      @source = Source.find(params[:id])
      if @source.update_attributes(clear_params)
        redirect_to @source, :notice => 'Source was successfully updated.'
      else
        render :action => "edit"
      end
    end

    def destroy
      @source = Source.find(params[:id])
      @source.destroy
      redirect_to sources_url
    end

    private
      def clear_params
        if defined?(::ActionController::StrongParameters)
          params.require(:source).permit(:identifier, :url, :api_key)
        else
          params[:source]
        end
      end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lit-0.2.4 app/controllers/lit/sources_controller.rb
lit-0.2.3 app/controllers/lit/sources_controller.rb
lit-0.2.2 app/controllers/lit/sources_controller.rb