Class: CompletionKit::DatasetsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- CompletionKit::DatasetsController
- Includes:
- TagFiltering
- Defined in:
- app/controllers/completion_kit/datasets_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/completion_kit/datasets_controller.rb', line 31 def create @dataset = Dataset.new(dataset_params) if @dataset.save redirect_to datasets_path, notice: "Dataset was successfully created." else render :new, status: :unprocessable_entity end end |
#destroy ⇒ Object
49 50 51 52 |
# File 'app/controllers/completion_kit/datasets_controller.rb', line 49 def destroy @dataset.destroy redirect_to datasets_path, notice: "Dataset was successfully destroyed." end |
#edit ⇒ Object
28 29 |
# File 'app/controllers/completion_kit/datasets_controller.rb', line 28 def edit end |
#index ⇒ Object
6 7 8 |
# File 'app/controllers/completion_kit/datasets_controller.rb', line 6 def index @datasets = apply_tag_filter(Dataset.includes(:runs, :tags).order(created_at: :desc)) end |
#new ⇒ Object
24 25 26 |
# File 'app/controllers/completion_kit/datasets_controller.rb', line 24 def new @dataset = Dataset.new end |
#show ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/controllers/completion_kit/datasets_controller.rb', line 10 def show @runs = @dataset.runs.includes(:prompt, :responses).order(created_at: :desc) respond_to do |format| format.html format.csv do slug = @dataset.name.to_s.parameterize.presence || "dataset-#{@dataset.id}" send_data @dataset.csv_data.to_s, type: "text/csv", filename: "#{slug}.csv", disposition: "attachment" end end end |
#update ⇒ Object
41 42 43 44 45 46 47 |
# File 'app/controllers/completion_kit/datasets_controller.rb', line 41 def update if @dataset.update(dataset_params) redirect_to @dataset, notice: "Dataset was successfully updated." else render :edit, status: :unprocessable_entity end end |