Class: Lit::SourcesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/lit/sources_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



38
39
40
41
42
43
44
45
# File 'app/controllers/lit/sources_controller.rb', line 38

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

#destroyObject



56
57
58
59
60
# File 'app/controllers/lit/sources_controller.rb', line 56

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

#editObject



17
18
19
# File 'app/controllers/lit/sources_controller.rb', line 17

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

#indexObject



5
6
7
# File 'app/controllers/lit/sources_controller.rb', line 5

def index
  @sources = Source.all
end

#newObject



13
14
15
# File 'app/controllers/lit/sources_controller.rb', line 13

def new
  @source = Source.new
end

#showObject



9
10
11
# File 'app/controllers/lit/sources_controller.rb', line 9

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

#sync_completeObject



62
63
64
65
# File 'app/controllers/lit/sources_controller.rb', line 62

def sync_complete
  @source = Source.find(params[:id])
  render json: { sync_complete: @source.sync_complete }
end

#synchronizeObject



21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/lit/sources_controller.rb', line 21

def synchronize
  @source = Source.find(params[:id])
  @source.update_column(:sync_complete, false)
  if defined?(ActiveJob)
    SynchronizeSourceJob.perform_later(@source)
  else
    @source.synchronize
  end
  redirect_to lit.source_incomming_localizations_path(@source)
end

#touchObject



32
33
34
35
36
# File 'app/controllers/lit/sources_controller.rb', line 32

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

#updateObject



47
48
49
50
51
52
53
54
# File 'app/controllers/lit/sources_controller.rb', line 47

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