vendredi 3 avril 2015

Rails4 Paperclip: How to display file chosen in Edit view, and reset it from a post?


Vote count:

0




Using Paperclip with Rails4.


I want to see the current image name displayed when I Edit a post. Blank if the default missing.png, otherwise show the value if available. I can use the Paperclip image_file_name method to see it in the rails console and the Show view, but not the Edit view. If I use:



#use in Show -ok
<%= image_path @post.image_file_name %>

#displays in Show
/images/blah.png

#use in Edit iteration -fails
<%= image_path f.image_file_name %>

#NoMethodError on image_file_name


I don't need it in the Show as the image is the main point. I would like to find out how to show the filename in the Edit view, so that the user can see what the current image name is. I know what my problem is, I want to see the value separate from editing it, in the Edit view.


Currently is says no file chosen when that's false. This area needs the following function: I need to find out how to clear the image selected in the Edit view, and show what it is if present.


Any direction appreciated.


P.S.


Also for whatever it is, would this be how to test it?



<% if f.image_file_name != "/images/missing.png" %>
<%= f.image_file_name %>
<% end %>


P.P.S


Can I get rid of showing /images directory and just show only the file name?


Cheers



asked 1 min ago

sf2k

164






Rails4 Paperclip: How to display file chosen in Edit view, and reset it from a post?

Aucun commentaire:

Enregistrer un commentaire