I have done a lot of web searches to see if I could find a script where I could popup a QR code image in my Rails application. I came across Lightbox 2. I have installed the scripts and copied the CSS code in my stylesheet.
I tried to use the following code. I tried to include the path where the image is located. The page displays fine when QR Code is clicked but there is no image.
QR Code
I would like to know if I can define the path for this image using the code above or will I need to use some kind of rails statement to do this?
I have been doing searching for a couple of hours and had found several suggestions, including on Stack Overflow. However I have not seen any examples that stated that they were used in Rails applications.
Any help would be appreciated.
inside the html.erb file
<%= link_to image_tag("small_image", :size => "76x76"),'/assets/large_image.png',:rel => "lightbox"%>
image_tag is for show small thumbnail preview, make sure actual image path is /assets/image_file
if you use ordinary html tags its fine
<a href="/assets/images_file" rel="lightbox" >My Image</a>
Related
I started my journey with Rails and Ruby a couple of days ago and so far it is going well and I'm loving it!
Though, I do have a minor concern that I cannot find a solution to. I've had a minor sneak peek on turbolink and how that is embedded with Rails. But, my question (problem?) is that whenever I import/include an image (which is located in app/assets/image) with Rails image_tag(...), that image is reloaded whenever I redirect to another page. But if I use <img src="..." whereas the src is an extern link (image fetched from another page) it is not being re-fetched (meaning, it's cached when I redirect to another page).
So my question is: is there a special way to apply turbolink to image_tag?
Thanks.
This is because you are running in development mode. Rails uses an "Asset Pipeline. When in development environment it reloads the assets.
When you come to production, you will see the difference.
You can read more about it here: http://guides.rubyonrails.org/asset_pipeline.html
currently we are working on a web tool using Ruby on Rails and one of their functions is generate a PDF report based in HTML template, that template has a map built with leaflet-0.7.3 and we are using a gem called pdfkit v0.8.2, wkhtmltopdf-binary v0.9.9.3 to generate PDFs, but right now we are facing an issue with that report, when It generates that report it is splitting the map and layers like this:
PDF error
It is supposed to look like this
Expected result
Any suggestions what's going on? or what should we do?
Any help would be great for us! thank you guys
I was facing a similar issue with my HTML template when It was generated, so, I solved it replacing my leaflet stylesheet with the last version, which is
http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css
please, replace your current stylesheet and share me what was your result.
I am integrating a Angular app with Rails and I have a problem with accessing the images. Angular app has a lots of path to images with structure: (for example)
src="assets/img/layout/ico-przystawki.png"
But that doesn't work in a Rails application, because I shouldn't be using the 'img' part. It should be like this:
src="assets/layout/ico-przystawki.png"
Is there a way to tell Rails application to use direct paths to images, so that I don't have to change every time these paths?
I found myself using the non-stupid-digest-assets gem for this very purpose. See https://github.com/alexspeller/non-stupid-digest-assets
Stop assets precompile and then you can access all img (and assets file) with src="assets/ut/ico-przystawki.png"
Try to use the provided rails helper method image_tag instead when you call an image:
<div>
<%= image_tag("ico-przystawki.png") %>
</div>
Read more about that here:
http://apidock.com/rails/ActionView/Helpers/AssetTagHelper/image_tag
I copied this question from https://groups.google.com/forum/#!msg/rubyonrails-talk/9Wfid1pYP7w/qqSIiW45L_8J
I have the same problem with him, please help me, thanks a lot
Hello Everyone,
I am using Wicked Pdf to generate pdf file.
In my model, i have method to generate pdf file.
I also need to show image in my pdf file from amazon s3.
Case 1:
i tried using
While i am running that method image not displaying, just a small box only appearing insteat of image.
Case 2:
i tried <%= image_tag(#image.avatar)%>
While i run this, i am getting "rake aborted!
undefined method `image_tag' for main:Object"
i googled this problem but no clear answer... any help..
First of all you need to use wicked_pdf_image_tag to show images in pdf. Try it with some local image:
<%= wicked_pdf_image_tag "some_image.jpg" %>
This should work.
Then try it with s3 image. If image doesn't show up, this mean that you using old version of wkhtmltopdf library. Download new version from http://wkhtmltopdf.org/downloads.html
So I've been banging my head on this all day yesterday trying to get PDF rendering to work properly. After trying Prawn and PDFKit, I found that the problem with at least getting it to work at all had to do with wkhtmltopdf on Mac OS 10.7, but now the problem is that it completely ignores any styles I add targeting the pdf, the print media type, and any special templates.
Here is a pastebin of where I'm at now: http://pastebin.com/LW16RYjW
Trying all of these and several others didn't work for me:
http://www.snikt.net/blog/2012/04/26/wicked-pdf/
WickedPDF missing layout
http://akabhilash.wordpress.com/2010/11/27/pdf-generation-with-wicked-pdf-in-rails/
I finally got to this setup:
https://github.com/mileszs/wicked_pdf/issues/87
Not knowing what else to do, I physically copied pdf_helper.rb into my lib/ directory (I don't know why it wasn't there before, or even whether it should've been upon bundling(?))
Can anyone tell me why it doesn't seem to be picking up any of the rendering options in the controller, and how I can get the styles to register without affecting the screen (html) version? Any help would be greatly appreciated. Thanks in advance for your time.
Turn off the middleware, or add the route you are trying to customize in the middleware call as documented in the README.