rqrcode on ruby rails - ruby

I tried the example in this website:
https://richonrails.com/articles/generating-qr-codes-in-your-ruby-on-rails-application
to generate a qr code. there seems to be a problem with the require 'rqrcode' line which I have in the config/environment.rb file.
I checked that the gem is installed and it is. I removed the line require 'rqrcode' from the config/environment.rb file and then I get error 'uninitialized constant QrCodesController::RQRCode' at the controller:
def create
#qr = RQRCode::QRCode.new(qr_code_params[:text],size:4)
end
when I re-add the line require 'rqrcode' and restart the rails server, I get the error - 'require': cannot load such file - rqrcode (LoadError).
Thanks in advance for the help!

Related

Ruby on Rail running apache show index of when accessing the site

I have recently updated to Apache 2.4, and I am using Ruby on Rail to run my application. Following the upgrade, the site shows a content as seen in the image below, and the error on the log file shows this error message. I have tried using the 'Bundle Install' and checked the permission but that hasn't helped. Any advice would be greatly appreciated. Thanks
[ 2022-02-07 07:47:24.5559 8104/7efc89c8f700 age/Cor/App/Implementation.cpp:304 ]: Could not spawn process for application /home/adminuser/hroot: An error occured while starting up the preloader.
Error ID: ba7e6074
Error details saved to: /tmp/passenger-error-RA01E9.html
Message from application: libmysqlclient.so.18: cannot open shared object file: No such file or directory - /usr/local/rvm/gems/ruby-2.0.0-p353#hroot/gems/mysql2-0.3.14/lib/mysql2/mysql2.so (LoadError)
PassengerRuby /usr/local/rvm/gems/ruby-2.0.0-p353#hroot/wrappers/ruby
SetEnv GEM_HOME /root/.gem/ruby/1.9.1
This error shows a problem with the shared objects. You probably updated MySQL/MariaDB libraries with Apache and new libraries are incompatible with your mysql2 gem build. The solution is simple:
First, ensure you are using the ruby-2.0.0-p353#hroot RVM environment.
Then, execute the following command:
gem install mysql2 --version 0.3.14
This should rebuild your mysql2 gem for the new MySQL/MariaDB client libraries on your system.
this isn't the answer anyway but another method to run ruby (in my case Windows 10 ; if you use another OS try to find out how to modify inside index.php the ruby starter)
i post here an alternative method to use apache + php +... and ruby
https://stackoverflow.com/a/71733656/5781320

When running an application under ruby 2.3.1 using the rails server command, the following error occurs: can not modify a frozen array (RuntimeError)

I have to run an application developed in Ruby on rails. ruby 2.3.1 and rails 4.2.0
When I execute the rails server command. I get the following error:
.... config / initializers / doorkeeper.rb: 75: in <top (required)>: can not modify a frozen array (RuntimeError).
Can I explain how to succeed to no longer have this error, thank you
Info :
The "bundle install" command runs successfully.
The code around doorkeepee.rb near line 75 : Doorkeeper.configuration.token_grant_types << "password"
I'm trying to understand how RAIL_ENV works. Can you help me at the same time?

Why could `rb_sysopen` not be found anymore by the custom fact since the upgrade to Puppet4?

The following custom fact:
# returns latest packerversion, e.g. 0.10.1
Facter.add("latest_packerversion") do
setcode do
url="https://www.packer.io/downloads.html"
file = open("#{url}")
contents = file.read()
match = contents.match(/Latest\sversion:\s(.*)</)
match[1]
end
end
worked using puppet 3.6.2, but since the upgrade to 4.5.2 the following issue occurs:
Error: Facter: error while resolving custom fact "latest_packerversion":
No such file or directory # rb_sysopen - https://www.packer.io/downloads.html
Analysis
It seems that the rb_sysopen could not be found anymore for some reason (No such file or directory # rb_sysopen) since the upgrade to Puppet 4.
Puppet4 seems to use an embedded ruby version instead of the one installed on the host (Puppet3):
Puppet 4, both Facter 2.4 and CFacter 0.4, the latest Hiera and
Mcollective, as well Ruby 2.1.5, OpenSSL 1.0.0r, and our gem
dependencies.
Does rb_sysopen not exist in Ruby 2.1.5? No evidence was found.
Perhaps a change related to facts have occurred that could cause the issue? Nothing related was found in the release notes.
Question
Why could rb_sysopen not be found anymore by the custom fact since the upgrade to Puppet4?
Concise
I will include require 'open-uri' in both facts, but I do not understand why this is required since the upgrade to Puppet4
Verbose
Once require 'open-uri' is included in one of the custom facts the issue is solved.
# returns latest gitversion, e.g. 2.8.2
Facter.add("latest_gitversion") do
setcode do
require 'open-uri'
url="https://git-scm.com/downloads"
file = open("#{url}")
contents = file.read()
match = contents.match(/RelNotes.*((\d\.){2}\d)/)
match[1]
end
end
As soon as the require 'open-uri' has been commented out, the issue occurs again:
Error: Facter: error while resolving custom fact "latest_gitversion": No such file or directory # rb_sysopen - https://git-scm.com/downloads
Error: Facter: error while resolving custom fact "latest_packerversion": No such file or directory # rb_sysopen - https://www.packer.io/downloads.html
At the moment it is unclear what is causing the issue.

Ruby PDFLib on OSX: LoadError in require

I just downloaded and installed the Ruby for OSX version of PDFLib (from pdflib.com).
I am using the following setup:
ruby 1.9.3p429 (2013-05-15 revision 40747) [x86_64-darwin12.4.0]
OSX Yosemite 10.10.4
PDFLib 9.0.5
The require 'PDFLib' statement in my Ruby file produces the following error message:
/Users/[...]/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in 'require': dlsym(0x7ff6e3ef4b90, Init_PDFLib): symbol not found - [...]/PDFLib.bundle (LoadError)
So it seems that the Ruby interpreter cannot find the Init_PDFLib in the library. But from the output of nm I gather that this symbol seems to be present:
$ nm -g ./PDFlib.bundle | grep -i init
0000000000001200 T _Init_PDFlib
[...]
Has anyone any idea what goes wrong? Thanks in advance for your answers.
Found it!
The PDFlib file is called PDFlib.bundle (small l), and my code did a require 'PDFLib' (capitalized L).
It turns out that the require does load the bundle file regardless of the wrong capitalization, but then searches for the Init_PDFLib symbol, which is not present.
So changing the require statement to require 'PDFlib' (small l) worked.

RDF-raptor-parser

I am trying to parse the rdf file but
I am getting error while executing following code in ubuntu
RDF::Reader.open("http://datagraph.org/jhacker/foaf.rdf") do |reader|
reader.each_statement do |statement|
puts statement.inspect
end
end
as
LoadError: Could not open library 'libraptor': libraptor: cannot open shared object file: No such file or directory. Could not open library 'libraptor.so': libraptor.so: cannot open shared object file: No such file or directory
I installed all the required gems:
rdf
rdf-raptor
ffi
rdf-json
rdf-trix
Please help me how to rectify this problem
I suggest you visit http://rdf.rubyforge.org/raptor/ and use the contact info mentioned there such as the mailing list. The error is because the C shared library libraptor.so cannot be found by ruby, so it must have been installed in a non-standard place. I am the author of Raptor but I do not know how rdf-raptor installed Raptor.

Resources