Class: RangedLotCategoriesController

Inherits:
ApplicationController show all
Includes:
DataControllerConfiguration::ProjectDataControllerConfiguration
Defined in:
app/controllers/ranged_lot_categories_controller.rb

Instance Attribute Summary

Attributes inherited from ApplicationController

#is_data_controller, #is_task_controller, #meta_data, #meta_description, #meta_keywords, #meta_title, #page_title, #site_name

Instance Method Summary (collapse)

Methods inherited from ApplicationController

#clear_project_and_user_variables, #digest_cookie, #digested_cookie_exists?, #disable_turbolinks, #intercept_api, #invalid_object, #is_data_controller?, #is_task_controller?, #log_user_recent_route, #notice_user, #project_matches, #record_not_found, #set_project_and_user_variables, #set_project_from_params, #token_authenticate

Methods included from ProjectsHelper

#project_link, #project_tag, #projects_list, #projects_search_form

Instance Method Details

- (Object) create

POST /ranged_lot_categories POST /ranged_lot_categories.json



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/controllers/ranged_lot_categories_controller.rb', line 29

def create
  @ranged_lot_category = RangedLotCategory.new(ranged_lot_category_params)

  respond_to do |format|
    if @ranged_lot_category.save
      format.html { redirect_to @ranged_lot_category, notice: 'Ranged lot category was successfully created.' }
      format.json { render :show, status: :created, location: @ranged_lot_category }
    else
      format.html { render :new }
      format.json { render json: @ranged_lot_category.errors, status: :unprocessable_entity }
    end
  end
end

- (Object) destroy

DELETE /ranged_lot_categories/1 DELETE /ranged_lot_categories/1.json



59
60
61
62
63
64
65
# File 'app/controllers/ranged_lot_categories_controller.rb', line 59

def destroy
  @ranged_lot_category.destroy
  respond_to do |format|
    format.html { redirect_to ranged_lot_categories_url }
    format.json { head :no_content }
  end
end

- (Object) download

GET /ranged_lot_categories/download



72
73
74
# File 'app/controllers/ranged_lot_categories_controller.rb', line 72

def download
  send_data RangedLotCategory.generate_download( RangedLotCategory.where(project_id: $project_id) ), type: 'text', filename: "ranged_lot_categories_#{DateTime.now.to_s}.csv"
end

- (Object) edit

GET /ranged_lot_categories/1/edit



24
25
# File 'app/controllers/ranged_lot_categories_controller.rb', line 24

def edit
end

- (Object) index

GET /ranged_lot_categories GET /ranged_lot_categories.json



8
9
10
11
# File 'app/controllers/ranged_lot_categories_controller.rb', line 8

def index
  @recent_objects = RangedLotCategory.recent_from_project_id($project_id).order(updated_at: :desc).limit(10)
  render '/shared/data/all/index'
end

- (Object) list



67
68
69
# File 'app/controllers/ranged_lot_categories_controller.rb', line 67

def list
  @ranged_lot_categories = RangedLotCategory.with_project_id($project_id).order(:id).page(params[:page])
end

- (Object) new

GET /ranged_lot_categories/new



19
20
21
# File 'app/controllers/ranged_lot_categories_controller.rb', line 19

def new
  @ranged_lot_category = RangedLotCategory.new
end

- (Object) ranged_lot_category_params (private)

Never trust parameters from the scary internet, only allow the white list through.



85
86
87
# File 'app/controllers/ranged_lot_categories_controller.rb', line 85

def ranged_lot_category_params
  params.require(:ranged_lot_category).permit(:name, :minimum_value, :maximum_value)
end

- (Object) set_ranged_lot_category (private)

Use callbacks to share common setup or constraints between actions.



79
80
81
82
# File 'app/controllers/ranged_lot_categories_controller.rb', line 79

def set_ranged_lot_category
  @ranged_lot_category = RangedLotCategory.with_project_id($project_id).find(params[:id])
  @recent_object = @ranged_lot_category 
end

- (Object) show

GET /ranged_lot_categories/1 GET /ranged_lot_categories/1.json



15
16
# File 'app/controllers/ranged_lot_categories_controller.rb', line 15

def show
end

- (Object) update

PATCH/PUT /ranged_lot_categories/1 PATCH/PUT /ranged_lot_categories/1.json



45
46
47
48
49
50
51
52
53
54
55
# File 'app/controllers/ranged_lot_categories_controller.rb', line 45

def update
  respond_to do |format|
    if @ranged_lot_category.update(ranged_lot_category_params)
      format.html { redirect_to @ranged_lot_category, notice: 'Ranged lot category was successfully updated.' }
      format.json { render :show, status: :ok, location: @ranged_lot_category }
    else
      format.html { render :edit }
      format.json { render json: @ranged_lot_category.errors, status: :unprocessable_entity }
    end
  end
end