QR Code Plugins Issue - Jeff - ruby-on-rails

I used a plugin to create A QR Code from a plugin which says to use the below code in ruby page
<%= javascript_include_tag :defaults %>
<%= qrcode('http://www.facebook.com/', 2, 3, 'my-qrcode') %>
I was expecting an image file , instead i got a table with lots of values in it. I tried a different ways to find a QRCode image generator and the only one seems to give an image is google charts, which i find not that interesting, I used them like
<%= image_tag("http://chart.apis.google.com/chart?cht=qr&chl=#{'http://www.facebook.com/'}&chs=120x120&choe=UTF-8", :size => "120x120")%>
Does anyone knows any other useful plugin that gives me the following output
I need to see a QR code for a link (where the parameters of the link
changes)
When i click on a link below it, it should be able to download the
QRCode image.

Take a look into rqrcode. It seems to do what you want.
There is an old example app here

Related

How do I display metrics in a custom SonarQube Plugin?

I'm working on a Java SonarQube plugin, but am still new to the API and making plugins in general.
I've downloaded the Example SonarQube Plugin (from https://github.com/SonarSource/sonar-examples) and have been playing around with it to try get the hang of it.
For a start, I'm trying to simply show the number of Lines of Code of a selected program. In the html.erb part, I have just added some "Hello World" text as seen below:
<div> Hello World </div>
I already added the metrics option so I think I'm just missing something small.
#WidgetProperty(key = "Metric",
type = WidgetPropertyType.METRIC,
description = "Select a metric (at least one is necessary).",
optional = false )
Essentially, I just want to click the Lines of Code metric in the widget options and display its output.
Any ideas? Thank you very much in advance!
The way to solve the issue is as follows:
Assuming your "Metric" input is as in the question above, the following code in the html.erb file should do the trick in displaying the value of the selected metric.
<h3 align="center"><%= widget_properties['Metric'].description -%></h3>
<%= format_measure(widget_properties['Metric'].key, :url => url_for_drilldown(widget_properties['Metric'].key)) -%>
Hope this helps anyone with the same problem.

Render images into my post content

I'm trying to add images to my post which I thought that would be easier but god I've been struggling for a while now.
I tried to use Redcarpet and added some ruby Image_tag code but didn't work. Also I tried with tag and the raw method but no luck. I don't know I've been going around but I couldn't fine anything and I think I'm not asking nothing weird or complicated ahah.
Just add pictures from my /assets/images folder if is possible.
<%= img_tag ("my_photo.jpg")%>
How do you recommend to do it?
Many thanks
I use the image_tag helper and this has always worked fine for me. You could try this:
<%= image_tag("my_photo.jpg")%>
I figured it out. I used HTML tag instead of Ruby code.
<%= raw (#post.content) %>
As I am using assets pipeline:
<img src="/assets/my_photo.jpg" alt="twd" class="img-rounded"></img>
My issue was that I was calling my photo as /images/my_photo.jpg instead of /assets/my_photo.jpg... simple as that

How to call an external website image with image_tag in a .html.erb?

How can I call an image of some url external website using image_tag in a rails html view? Please, I'm looking for an alternative using image_tag not the regular html or css
EDIT Turns out OP wanted to do this b/c Heroku wasn't pulling in images from the assets folder. It is an issue that is easily resolved by reading/following the instructions here: Rails 4 images not loading on heroku .
Leaving the original answer here as it more correctly answers the original question.
image_tag works with full urls. So you could just give it the URL to the site you want to pull from. i.e:
<%= image_tag 'https://placekitten.com/800/400' %>
I'm sure you are already aware of this, but in 99.999% of situations, hot-linking images from other sites is a very bad idea.
Say you have an SVG file that is the image and it points to your Github or Linkedin profile, you could do something like this:
Setup:
In app/images/, you have some image file. For example, linkedin.svg.
Procedure
In your html.erb file, add:
<%= link_to image_tag("linkedin.svg"), "http://www.linkedin.com/in/myprofile", :target => "_blank"%>
Wait!!!!! READ CAREFULLY
Pay close attention to the space between image_tag and the parentheses(the method and the argument).
Some examples that you'll find online show a space between the image_tag and the argument. Keep them together.
Check the commas.
Last, just to be safe, make sure your link includes "http://www....."

rails 3 is printing html tags to screen instead of rendering them

I'm using vhochstein's fork of active_scaffold, which runs quite nicely on rails 3, except for a few small bugs - http://github.com/vhochstein/active_scaffold.
In rails 2.3, the following code disables a link:
return "<a class='disabled'>#{text}</a>" unless authorized
But in Rails 3, it causes the escaped html tags to be printed out instead as in the following photo:
How can I make the content of this return statement render the way it should in rails 3?
The code above, is from the list_column_helpers.rb file in vendor/plugins/active_scaffold/helpers/
UPDATE:
Floatless fixed this by suggesting to add .html_safe to the code.
I have since found that the folowing change also needs to be made as there's more than one bit of code that is respondible for disabling action links in active_Scaffold:
In /plugins/active_scaffold/frontends/default/views/_list_actions.html.erb change:
<%= record.authorized_for?(:crud_type => etc etc etc -%>
By making it use "raw"
i.e.
<%= raw record.authorized_for?(:crud_type => etc etc etc -%>
Anyway, thanks to floatless and hopefully mr hochstein will be able to use this stuff.
Try this:
return "<a class='disabled'>#{text}</a>".html_safe unless authorized

Multiple Markers on Google Map (Fails to display over 10 markers) - Ruby on Rails Environment YM4R Plugin

I have the following issue. I have a google map (using YM4r + Geokit) within Ruby on Rails, anyhow, i basically have an array of markers which are populated in the following manner
#shops.each do
|sto|
markers << GMarker.new (....)
end
They are definitely being stored fine as under 10 markers they are displayed just fine. The problem arises when there are more than 10 markers on the same page,
Further code related to displaying if this may help:
#map.overlay_global_init(GMarkerGroup.new(true, markers), "sto_markers")
in the html.erb file:
<%= GMap.header %>
<%= javascript_include_tag("markerGroup") %>
<%= #map.to_html%>
<%= #map.div(:width => 700, :height => 500)%>
Only 10 markers are displayed on screen instead of the correct amount in the markers array.
Has anyone ever encountered this issue please? i'm really at a loss on how to overcome this please
Hmm, I have never used these plugins (I prefer to work directly with the API, much easier :)), so this is just random thinking.
Have you looked in the source of the rendered HTML? In there you should have a Javascript Object or Array with all your markers defined. If all of them do show up there, then it is easier to pinpoint if the problem is on the Javascript or the Rails side. (That is what <%= #map.to_html%> should do unless I'm completely off).
Update:
After some looking into the plugin, I can't really tell what the error can be, however since it do put out everything in clear Javascript in the file, it would probably help a lot if you can post the rendered HTML source. I believe that you will find the solution by looking there.

Resources