I am using:
ruby 1.8.7, rails 2.3.5
ruby gems 1.3.6
Windows 7 Home Basic 64-bit
barby 0.5.0
I'm having problems to generate barcodes for my app. I installed barby 0.5.0 and I was hoping that it would solve my problems. But everytime it generates a file, it seems that it's broken or damaged. It can't be opened. I wonder what I'm doing wrong here.
As for the stack trace, there's really no error.
Here's my code:
barcodevalue = "00000000000"
full_path = "barcode#{barcode_value}.png"
barcode = Barby::Code39.new(barcode_value)
File.open(full_path, 'w') { |f| f.write barcode.to_png(:margin => 3, :xdim => 2, :height => 55) }
render :text => "#{barcode_value}.png has been generated."
Please see this link for answer.
https://groups.google.com/forum/#!topic/ruby-barby/8Vgh-CLNfuI
Related
I am using axlsx_rails in my Rails project to generate an excel file with validations and dropdowns. After generating the File, I tried to open the file in MS Excel and it said that it needs to repair the file and all the validations and dropdowns are cleared off.
Versions
axlsx_rails - 0.1.5
axlsx - 1.3.6
rubyzip - 1.2.0
rails - 4.1.2
ruby - 2.2.2
Code
#excel = Axlsx::Package.new
#excel.workbook.add_worksheet(name: "Samples") do |ws|
ws.add_row #field_names
sheet.add_data_validation("G2:G1000", {
:type => :list,
:formula1 => '"Jim", "Tom", "Jack"',
:showDropDown => false,
:showErrorMessage => true,
:errorTitle => '',
:error => 'Please use the dropdown selector to choose the value',
:errorStyle => :stop,
:showInputMessage => true,
:prompt => 'Choose the value from the dropdown'})
end
#excel.serialize "tmp/SampleTemplate.xlsx"
Sending the file using
send_file "tmp/SampleTemplate.xlsx"
The generated file is working in LibreOffice but not in MSExcel
Please help
Solved. The issue is in the line,
:formula_1 => '"Jim", "Tom","Jack"'
I've changed it to,
:formula_1 => '"Jim, Tom, Jack"'
i am using wickedpdf gem to generate pdf invoice from the html code.
gems:
gem 'wicked_pdf'
gem "wkhtmltopdf-binary"
gemfile.lock
wicked_pdf (1.0.6)
wkhtmltopdf-binary (0.9.9.3)
in controller:
def show_pdf_invoice
respond_to do |format|
format.html { render :layout => "pdf.pdf.erb" }
format.pdf do
render pdf: "show_pdf_invoice", :layout => 'pdf.pdf.erb'
#render :pdf => "pdf"#, :layout => 'pdf.html.erb'
end
end
end
in views/invoices/show_pdf_invoice.pdf.erb
<img id="image" src="https://www.google.co.in/logos/doodles/2016/holidays-2016-day-2-6356741311692800-scta.png" alt="logo" />
<%= wicked_pdf_image_tag 'https://www.google.co.in/logos/doodles/2016/holidays-2016-day-2-6356741311692800-scta.png' %>
pdf is getting generated. But the images are not showing. in the place of images empty boxes are coming. unable to find the issue.
I've had the same problem, mine was fixed by removing https for http. Have you tried this? and for the Amazon S3 part: You could use gsub for that as in: gsub("https", "http")
Using Rails 5.2 with Active Storage in combination with Amazon S3 storage I had the same problem.
In development on my local machine the images rendered perfectly, but on Heroku
they were presented as small empty rectangles.
To get the url from the logo uploaded to Active Storage I used: #my_object.logo.service_url.
Which used the standard url with https. As mentioned before, replacing this with http resolved the issue.
Full code used in my pdf generator view:
<%= wicked_pdf_image_tag #my_object.logo.service_url.gsub("https", "http") %>
Two Options
1. Upgrade to wkhtmltopdf 0.12.5.
-or-
2. Install libssl1.0-dev with apt-get install libssl1.0-dev.
See this issue for more information: https://github.com/wkhtmltopdf/wkhtmltopdf/issues/3001
I'm getting an extra white space inside the text area when rendering this HAML code.
= f.text_area :message, placeholder: "Reply"
I'm running Rails 3.2.3 and haml-rails 0.3.4 and haml 3.1.4
I have no idea why this is happening.
This is the code rendered with the extra whitespace
<textarea class="textarea" cols="50" id="idea_idea" name="idea[idea]" rows="2">
</textarea>
Just found a solution to this problem.
I upgraded to the "3.1.5" beta version of HAML and works fine now.
gem 'haml', :git => "git://github.com/haml/haml.git", :branch => "315"
The version you are running should have similar issues fixed, see the ActionPack Changelog linked below, it appears to contain multiple entries related to the issue.
https://github.com/rails/rails/blob/3-2-stable/actionpack/CHANGELOG.md
I am trying to export data from a rails app and have the user download a CSV file when they hit a certain controller#action.
I found this article and used the sample code exactly.
http://oldwiki.rubyonrails.org/rails/pages/HowtoExportDataAsCSV
I do, in fact, get a CSV file, but within it, there is only one line of output:
#<Proc:0x00000001032c6808#/PATH_CRAP/app/controllers/reports_controller.rb:35>
Here are lines 35, 36 and 37 from the file in question.
render :text => Proc.new { |response, output|
csv = FasterCSV.new(output, :row_sep => "\r\n")
yield csv
I am using Rails 3.0.5 and added the following to my Gemfile:
gem 'fastercsv'
What gives?
render :text => proc {...} does not work in Rails 3. For the replacement, see this question.
I am developing a Rails 2.3.8 app and I stumbled upon a strange form error:
in all errors messages in any input forms, the variable count is not expanded.
As instance if I fill in the following form with a too long string (> 300 chars, I've set max=300), the form will display the message:
"is too long (maximum is {{count}} characters)" instead of:
"is too long (maximum is 300 characters)"
- form_for(#event) do |f|
= f.label :description
%br
= f.text_area :description
= f.error_message_on :description
Do you have any ideas why this happens ?
many thanks
Redmine had this issue and they fixed it in 1.0.5.
See here for the changes:
http://www.redmine.org/news/49
in the message they say something along these lines:
Among 11 bug fixes, Redmine 1.0.5
solves the incompatibility with the
i18n 0.5.0 gem. The appropriate i18n
gem version (0.4.2) is now required
so i assume you need to install the 0.4.2 i18n gem :)
I was having the same issue, and installing i18n 0.4.2 solved it for me.