画像投稿ボタンのCSS
なんとなく納得いかなかったけど忘れない為にメモ。
form_for
<label>
<span class="btn btn-primary">
<input type="file" style="display:none" name="product[product_image]" include_hidden="false" >
編集してください
</span>
</label>
end
こうなる。
name部分はProductモデルのproduct_image_idカラム。使用gemはrefile。
f.attachment_fieldだとうまいこといかなかったのでinputタグを使用。labelタグで囲わないと画像を選択できない。なんでや。
追記
後日動作を確認したら選択はできてもupdateがされてなかった。腹立ったし時間もないのでf.attachment_fieldのデフォルトで動かすことにする。あーもー!
Author And Source
この問題について(画像投稿ボタンのCSS), 我々は、より多くの情報をここで見つけました https://qiita.com/mameg725/items/c32b7073249f9d690280著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .