Class: ManifestationReserveStatsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/manifestation_reserve_stats_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /manifestation_reserve_stats POST /manifestation_reserve_stats.json



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'app/controllers/manifestation_reserve_stats_controller.rb', line 52

def create
  @manifestation_reserve_stat = ManifestationReserveStat.new(manifestation_reserve_stat_params)
  @manifestation_reserve_stat.user = current_user

  respond_to do |format|
    if @manifestation_reserve_stat.save
      ManifestationReserveStatJob.perform_later(@manifestation_reserve_stat)
      format.html { redirect_to @manifestation_reserve_stat, notice: t('statistic.successfully_created', model: t('activerecord.models.manifestation_reserve_stat')) }
      format.json { render json: @manifestation_reserve_stat, status: :created, location: @manifestation_reserve_stat }
    else
      format.html { render action: "new" }
      format.json { render json: @manifestation_reserve_stat.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /manifestation_reserve_stats/1 DELETE /manifestation_reserve_stats/1.json



87
88
89
90
91
92
93
94
# File 'app/controllers/manifestation_reserve_stats_controller.rb', line 87

def destroy
  @manifestation_reserve_stat.destroy

  respond_to do |format|
    format.html { redirect_to manifestation_reserve_stats_url }
    format.json { head :no_content }
  end
end

#editObject

GET /manifestation_reserve_stats/1/edit



47
48
# File 'app/controllers/manifestation_reserve_stats_controller.rb', line 47

def edit
end

#indexObject

GET /manifestation_reserve_stats GET /manifestation_reserve_stats.json



9
10
11
12
13
14
15
16
# File 'app/controllers/manifestation_reserve_stats_controller.rb', line 9

def index
  @manifestation_reserve_stats = ManifestationReserveStat.page(params[:page])

  respond_to do |format|
    format.html # index.html.erb
    format.json { render json: @manifestation_reserve_stats }
  end
end

#newObject

GET /manifestation_reserve_stats/new GET /manifestation_reserve_stats/new.json



37
38
39
40
41
42
43
44
# File 'app/controllers/manifestation_reserve_stats_controller.rb', line 37

def new
  @manifestation_reserve_stat = ManifestationReserveStat.new

  respond_to do |format|
    format.html # new.html.erb
    format.json { render json: @manifestation_reserve_stat }
  end
end

#showObject

GET /manifestation_reserve_stats/1 GET /manifestation_reserve_stats/1.json



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/manifestation_reserve_stats_controller.rb', line 20

def show
  if params[:format] == 'txt'
    per_page = 65534
  else
    per_page = ReserveStatHasManifestation.default_per_page
  end
  @stats = @manifestation_reserve_stat.reserve_stat_has_manifestations.order('reserves_count DESC, manifestation_id').page(params[:page]).per(per_page)

  respond_to do |format|
    format.html # show.html.erb
    format.json { render json: @manifestation_reserve_stat }
    format.txt
  end
end

#updateObject

PUT /manifestation_reserve_stats/1 PUT /manifestation_reserve_stats/1.json



70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'app/controllers/manifestation_reserve_stats_controller.rb', line 70

def update
  respond_to do |format|
    if @manifestation_reserve_stat.update(manifestation_reserve_stat_params)
      if @manifestation_reserve_stat.mode == 'import'
        ManifestationReserveStatJob.perform_later(@manifestation_reserve_stat)
      end
      format.html { redirect_to @manifestation_reserve_stat, notice: t('controller.successfully_created', model: t('activerecord.models.manifestation_reserve_stat')) }
      format.json { head :no_content }
    else
      format.html { render action: "edit" }
      format.json { render json: @manifestation_reserve_stat.errors, status: :unprocessable_entity }
    end
  end
end