iPhoneでJSのunloadが効かない時の対応
iPhoneだと別ページへ遷移するときとかに処理を入れたい場合使うunloadが無視されるためはまった。
pagehideを使うと別ページへ遷移する前に処理を行ってくれようになった
<script type="text/javascript"><!-- $(window).bind('pagehide',function(){ //ここに処理を入れる }); --></script>
これでとりあえず解決した
carrierwaveでversionsによって保存先ディレクトリを変更する方法
サムネイルと通常表示したい画像を別ディレクトリに保存したい場合にはまった。
versionの中にstore_dirを定義することで解決。
class ImageUploader < CarrierWave::Uploader::Base storage :file def store_dir "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" end version :thumb do process resize_to_fit: [50,50] def store_dir "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}/thumb" end def full_filename(for_file=model.image.file) super(for_file).chomp(File.extname(super(for_file))).sub(version_name.to_s + '_', '') + "_#{version_name.to_s}.jpg" end end end