On 29 February 2016 at 02:41, Elysee Montissol <lists@ruby-forum.com> wrote:
> I created a simple blog and I'm using paperclip to be able to add images
> to a Post. I installed the 'themify-icons-rails' gem and what I want to
> do is automatically add a picture icon next to the title of a post when
> the post has a image that's been uploaded, to show that the post has a
> image. I'm guessing I would need a If statement somewhere but I'm fairly
> new to rails and I'm not sure where to put it.
>
> <h2 class="ti-gallery"><%= link_to post.title, post %></h2> this adds
> the "Ti-gallery" icon to every post.
Assuming that what you want to leave out is the class specification
and assuming that post.image will be nil if there is no image (replace
that with something similar as necessary)
<h2 <%= "class=/"ti-gallery/"" if post.image %> >
<%= link_to post.title, post %>
</h2>
I have split it onto multiple lines to make it easier to read, that
will not affect the displayed page. The result of the code
"class=/"ti-gallery/"" if post.image
will either be the class= string or nil.
Colin
>
> Any Help will be greatly appreciated, Thank you before hand. Oh and one
> more questions, Is rails Video friendly? i can't seem to find any
> tutorials on uploading videos to a rails app.
>
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/050fa96f2643c768b05341ba1eefca74%40ruby-forum.com.
> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLs%2BS8eSS988_djyfOHHpt7j5dY0FasfeGHM84jArfQY8w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment