forked from snap-cloud/snapcon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcurrency_conversions_controller.rb
58 lines (48 loc) · 1.93 KB
/
currency_conversions_controller.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
module Admin
class CurrencyConversionsController < Admin::BaseController
load_and_authorize_resource :conference, find_by: :short_title
load_and_authorize_resource :currency_conversion, through: :conference
# GET /currency_conversions
def index; end
# GET /currency_conversions/1
def show; end
# GET /currency_conversions/new
def new
@currency_conversion = @conference.currency_conversions.new(conference_id: @conference.short_title)
end
# GET /currency_conversions/1/edit
def edit; end
# POST /currency_conversions
def create
@currency_conversion = @conference.currency_conversions.new(currency_conversion_params)
if @currency_conversion.save
redirect_to admin_conference_currency_conversions_path(@conference.short_title), notice: 'Currency conversion was successfully created.'
else
flash.now[:error] = 'Creating currency conversion failed.'
render :new
end
end
# PATCH/PUT /currency_conversions/1
def update
if @currency_conversion.update(currency_conversion_params)
redirect_to admin_conference_currency_conversions_path(@conference.short_title), notice: 'Currency conversion was successfully updated.'
else
flash.now[:error] = 'Updating currency conversion failed.'
render :edit
end
end
# DELETE /currency_conversions/1
def destroy
if @currency_conversion.destroy
redirect_to admin_conference_currency_conversions_path(@conference.short_title), notice: 'Currency conversion was successfully deleted.'
else
redirect_to admin_conference_currency_conversions_path(@conference.short_title), notice: 'Deleting currency conversion failed.'
end
end
private
# Only allow a list of trusted parameters through.
def currency_conversion_params
params.require(:currency_conversion).permit(:from_currency, :to_currency, :rate)
end
end
end