Class: LibraryGroupsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- LibraryGroupsController
- Defined in:
- app/controllers/library_groups_controller.rb
Instance Method Summary collapse
-
#edit ⇒ Object
GET /library_groups/1/edit.
-
#index ⇒ Object
GET /library_groups GET /library_groups.json.
-
#show ⇒ Object
GET /library_groups/1 GET /library_groups/1.json.
-
#update ⇒ Object
PUT /library_groups/1 PUT /library_groups/1.json.
Instance Method Details
#edit ⇒ Object
GET /library_groups/1/edit
39 40 41 |
# File 'app/controllers/library_groups_controller.rb', line 39 def edit @countries = Country.order(:position) end |
#index ⇒ Object
GET /library_groups GET /library_groups.json
7 8 9 10 11 12 13 14 |
# File 'app/controllers/library_groups_controller.rb', line 7 def index @library_groups = LibraryGroup.all respond_to do |format| format.html # index.html.erb format.json { render json: @library_groups } end end |
#show ⇒ Object
GET /library_groups/1 GET /library_groups/1.json
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/library_groups_controller.rb', line 18 def show respond_to do |format| format.html # show.html.erb format.json { render json: @library_group } format.download { if @library_group.header_logo.exists? if ENV['ENJU_STORAGE'] == 's3' file = Faraday.get(@library_group.header_logo.expiring_url(3600, :medium)).body.force_encoding('UTF-8') send_data file, filename: File.basename(@library_group.header_logo_file_name), type: @library_group.header_logo_content_type, disposition: :inline else file = @library_group.header_logo.path(:medium) if File.exist?(file) && File.file?(file) send_file file, filename: File.basename(@library_group.header_logo_file_name), type: @library_group.header_logo_content_type, disposition: :inline end end end } end end |
#update ⇒ Object
PUT /library_groups/1 PUT /library_groups/1.json
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/controllers/library_groups_controller.rb', line 45 def update respond_to do |format| if @library_group.update(library_group_params) if @library_group.delete_header_logo == '1' @library_group.header_logo.destroy end format.html { redirect_to @library_group, notice: t('controller.successfully_updated', model: t('activerecord.models.library_group')) } format.json { head :no_content } else @countries = Country.order(:position) format.html { render action: "edit" } format.json { render json: @library_group.errors, status: :unprocessable_entity } end end end |