Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ gem 'rails-i18n'
gem 'rails_config'
gem 'jquery-fileupload-rails'
gem 'carrierwave'
gem 'rmagick'
gem 'devise'
## 認可ライブラリ
gem 'cancancan', '~> 1.7'
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ GEM
ref (1.0.5)
responders (1.0.0)
railties (>= 3.2, < 5)
rmagick (2.13.2)
rspec (2.14.1)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
Expand Down Expand Up @@ -358,6 +359,7 @@ DEPENDENCIES
rails_config
rb-fsevent
redcarpet
rmagick
rspec-rails
sass-rails (~> 4.0.2)
selectize-rails
Expand Down
6 changes: 6 additions & 0 deletions app/uploaders/answer_file_uploader.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
# encoding: utf-8

class AnswerFileUploader < CarrierWave::Uploader::Base
include CarrierWave::RMagick

# Choose what kind of storage to use for this uploader:
storage :file

version :thumb do
process resize_to_fit: [200, 200]
end

# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
Expand Down
4 changes: 2 additions & 2 deletions app/views/answers/_viewer.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<% if file_form.object.is_pdf? %>
PDF
<% else %>
<%= image_tag file_form.object.image.url %>
<%= image_tag file_form.object.image.url(:thumb) %>
<% end %>
</a>
</li>
Expand All @@ -39,7 +39,7 @@
PDFを開く
<% end %>
<% else %>
<%= image_tag file.image.url, id: "file_#{file.id}" %>
<%= link_to image_tag(file.image.url(:thumb), id: "file_#{file.id}"), file.image.url, target: ['_blank'] %>
<% end %>
<% end %>
</div>
Expand Down