Class: Tiler::DataSourcesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/tiler/data_sources_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



19
20
21
22
23
24
25
26
# File 'app/controllers/tiler/data_sources_controller.rb', line 19

def create
  @data_source = DataSource.new(source_params)
  if @data_source.save
    redirect_to data_source_path(@data_source), notice: "Data source created."
  else
    render :new, status: :unprocessable_entity
  end
end

#destroyObject



39
40
41
42
# File 'app/controllers/tiler/data_sources_controller.rb', line 39

def destroy
  @data_source.destroy!
  redirect_to data_sources_path, notice: "Data source removed."
end

#editObject



28
29
# File 'app/controllers/tiler/data_sources_controller.rb', line 28

def edit
end

#indexObject



6
7
8
# File 'app/controllers/tiler/data_sources_controller.rb', line 6

def index
  @data_sources = DataSource.by_name
end

#newObject



14
15
16
17
# File 'app/controllers/tiler/data_sources_controller.rb', line 14

def new
  @data_source = DataSource.new(active: true,
                                ingestion_methods: [ "webhook", "manual" ].to_json)
end

#showObject



10
11
12
# File 'app/controllers/tiler/data_sources_controller.rb', line 10

def show
  @recent = @data_source.data_records.order(recorded_at: :desc).limit(25)
end

#updateObject



31
32
33
34
35
36
37
# File 'app/controllers/tiler/data_sources_controller.rb', line 31

def update
  if @data_source.update(source_params)
    redirect_to data_source_path(@data_source), notice: "Data source updated."
  else
    render :edit, status: :unprocessable_entity
  end
end