It is a huge project. There are many other developers too. The project is made on ruby on rails. Many of its modules are made in javascript. I want to detect bots and I haven't found any method to do that.
vendredi 29 avril 2022
mardi 26 avril 2022
returning the array created on a function to the initialize of a other function object
I'm making a simple "sell, client" program to practice in Ruby and I'm on a dilem taking the code, how is it possible to add the "itemsell" from the function "selecproduct" to the last argument on the init of object Venda (just where I tagged ##HELP##)
I'm having no problem in the process of add a Object as a variable, I'm just having the problem to return that value on one function to another one
def manipvendas
while true
puts "\n1- Adicionar venda"
puts ""
escolha = gets.chomp
return if escolhe == "0"
if escolha == "1" #adicionar venda
print "\nInsira o número da venda: "
numvend = gets.chomp
numvend = numvend.to_i
print "\nInsira a data da venda (Ano, Mês, Dia): "
ano = gets.chomp
mes = gets.chomp
dia = gets.chomp
data = Time.new(ano.to_i, mes.to_i, dia.to_i)
print "\nInsira o cliente (número pela ordem cadastrada) para o qual a venda foi feita: "
clientenum = gets.chomp
selecproduct
vendai = Venda.new(numvend,data,clientenum,##HERE##)
@vendas.push(vendai)
end
end
end
def selecproduct
while true
print "\nInsira o produto (número pela ordem cadastrada) vendido: "
print "Insira -1 para encerrar"
produtonum = gets.chomp
return if produtonum == "-1"
print "\n Insira a quantidade do produto vendida: "
produtoqnt = gets.chomp
valor = produtoqnt * @produtos[produtonum].get_valor
itemsell = ItemVenda.new(produtonum, @produtos[produtonum].get_valor, valor)
@itemvenda.push(vendaitem)
end
end
lundi 25 avril 2022
Query in rails with where array clause
I have an array field, author_ids in books table, I need to write a query to find the array data.
Is there any way i can get, even if author_ids has [1,3]
in its value, but when I check with array [1,5]
, I still could get the data because it has 1 common ? here('author_ids @> ARRAY[?]::integer[]',[1,5])
where('author_ids @> ARRAY[?]::integer[]',[1,5])
this doesnot return data, where('author_ids @> ARRAY[?]::integer[]',[1,3])
whis does because It has [1,3]. Iwant to get the data where [auther_ids] ? any [passed_aray]
samedi 23 avril 2022
#
I am debugging the each and every line of the code. Is this might be the reason for the occurrence of this error? If so then how can I debug the code?
For the eval_orchestration method, there is no method call but in the rails server this method is being hitted. Where the method call is happening?
module Va::OrchestrationNode
include Va::OrchestrationConstants
include Workflow::FunctionalDataUtil
include Va::Util
include Marketplace::ApiActions
include Metering::Helper
include Workflow::FunctionalNodesUtil
include Workflow::OsrCommonMethods
def eval_orchestration(node, evaluate_on)
######statements#
end
end
While running the server there is no call to the above method but in server it is hitting the lines in the eval_orcheatration method. It will be helpful for me if someone explains what is going on here?
WEBrick::HTTPStatus::EOFError: WEBrick::HTTPStatus::EOFError
While running the rails server, I am getting WEBrick::HTTPStatus::EOFError: WEBrick::HTTPStatus::EOFError. This error is being thrown from this file ....../gems/webrick-1.3.1/lib/webrick/httpserver.rb I am running the project it was working fine since yesterday I don't know why it is occurring now. I am not understanding why this is happening. I am new to ruby, can someone help?
vendredi 22 avril 2022
Error installing gems when creating new rails project (Windows)
I'm new to rails and I was following this guide when there was an error when I tried to run $ rails new blog
.
I'm running ruby 3.1.1p18
and Rails 7.0.2.3
on Windows
This is the output to the console:
$ rails new blog
create
create README.md
create Rakefile
create .ruby-version
create config.ru
create .gitignore
create .gitattributes
create Gemfile
run git init from "."
Initialized empty Git repository in C:/testrails/blog/.git/
create app
create app/assets/config/manifest.js
create app/assets/stylesheets/application.css
create app/channels/application_cable/channel.rb
create app/channels/application_cable/connection.rb
create app/controllers/application_controller.rb
create app/helpers/application_helper.rb
create app/jobs/application_job.rb
create app/mailers/application_mailer.rb
create app/models/application_record.rb
create app/views/layouts/application.html.erb
create app/views/layouts/mailer.html.erb
create app/views/layouts/mailer.text.erb
create app/assets/images
create app/assets/images/.keep
create app/controllers/concerns/.keep
create app/models/concerns/.keep
create bin
create bin/rails
create bin/rake
create bin/setup
create config
create config/routes.rb
create config/application.rb
create config/environment.rb
create config/cable.yml
create config/puma.rb
create config/storage.yml
create config/environments
create config/environments/development.rb
create config/environments/production.rb
create config/environments/test.rb
create config/initializers
create config/initializers/assets.rb
create config/initializers/content_security_policy.rb
create config/initializers/cors.rb
create config/initializers/filter_parameter_logging.rb
create config/initializers/inflections.rb
create config/initializers/new_framework_defaults_7_0.rb
create config/initializers/permissions_policy.rb
create config/locales
create config/locales/en.yml
create config/master.key
append .gitignore
create config/boot.rb
create config/database.yml
create db
create db/seeds.rb
create lib
create lib/tasks
create lib/tasks/.keep
create lib/assets
create lib/assets/.keep
create log
create log/.keep
create public
create public/404.html
create public/422.html
create public/500.html
create public/apple-touch-icon-precomposed.png
create public/apple-touch-icon.png
create public/favicon.ico
create public/robots.txt
create tmp
create tmp/.keep
create tmp/pids
create tmp/pids/.keep
create tmp/cache
create tmp/cache/assets
create vendor
create vendor/.keep
create test/fixtures/files
create test/fixtures/files/.keep
create test/controllers
create test/controllers/.keep
create test/mailers
create test/mailers/.keep
create test/models
create test/models/.keep
create test/helpers
create test/helpers/.keep
create test/integration
create test/integration/.keep
create test/channels/application_cable/connection_test.rb
create test/test_helper.rb
create test/system
create test/system/.keep
create test/application_system_test_case.rb
create storage
create storage/.keep
create tmp/storage
create tmp/storage/.keep
remove config/initializers/cors.rb
remove config/initializers/new_framework_defaults_7_0.rb
run bundle install
Fetching gem metadata from https://rubygems.org/...........
Resolving dependencies....
Using rake 13.0.6
Using racc 1.6.0
Using concurrent-ruby 1.1.10
Using minitest 5.15.0
Using builder 3.2.4
Using erubi 1.10.0
Using crass 1.0.6
Using rack 2.2.3
Using websocket-extensions 0.1.5
Fetching nio4r 2.5.8
Using marcel 1.0.2
Using mini_mime 1.1.2
Using digest 3.1.0
Using timeout 0.2.0
Using strscan 3.0.1
Fetching public_suffix 4.0.7
Fetching bindex 0.8.1
Using bundler 2.3.7
Fetching msgpack 1.5.1
Using matrix 0.4.2
Fetching regexp_parser 2.3.0
Fetching childprocess 4.1.0
Using method_source 1.0.0
Using thor 1.2.1
Using zeitwerk 2.5.4
Using rexml 3.2.5
Fetching rubyzip 2.3.2
Fetching sqlite3 1.4.2
Installing nio4r 2.5.8 with native extensions
Installing childprocess 4.1.0
Installing rubyzip 2.3.2
Installing bindex 0.8.1 with native extensions
Installing sqlite3 1.4.2 with native extensions
Installing regexp_parser 2.3.0
Installing msgpack 1.5.1 with native extensions
Installing public_suffix 4.0.7
Using nokogiri 1.13.4 (x64-mingw-ucrt)
Fetching net-protocol 0.1.3
Using mail 2.7.1
Using rack-test 1.1.0
Fetching websocket-driver 0.7.5
Installing websocket-driver 0.7.5 with native extensions
Installing net-protocol 0.1.3
Using i18n 1.10.0
Using tzinfo 2.0.4
Fetching sprockets 4.0.3
Using loofah 2.16.0
Fetching xpath 3.2.0
Fetching selenium-webdriver 4.1.0
Installing sprockets 4.0.3
Fetching addressable 2.8.0
Installing xpath 3.2.0
Using activesupport 7.0.2.3
Using net-imap 0.2.3
Using net-pop 0.1.1
Using net-smtp 0.3.1
Using rails-html-sanitizer 1.4.2
Fetching puma 5.6.4
Installing addressable 2.8.0
Installing selenium-webdriver 4.1.0
Installing puma 5.6.4 with native extensions
Using rails-dom-testing 2.0.3
Using globalid 1.0.0
Using activemodel 7.0.2.3
Using actionview 7.0.2.3
Using activejob 7.0.2.3
Using activerecord 7.0.2.3
Using actionpack 7.0.2.3
Fetching jbuilder 2.11.5
Using activestorage 7.0.2.3
Using actionmailer 7.0.2.3
Using railties 7.0.2.3
Using actionmailbox 7.0.2.3
Using actiontext 7.0.2.3
Fetching capybara 3.36.0
Fetching importmap-rails 1.0.3
Fetching stimulus-rails 1.0.4
Installing jbuilder 2.11.5
Installing importmap-rails 1.0.3
Fetching turbo-rails 1.0.1
Installing stimulus-rails 1.0.4
Fetching sprockets-rails 3.4.2
Installing capybara 3.36.0
Installing turbo-rails 1.0.1
Installing sprockets-rails 3.4.2
warning: no /var/cache/pacman/pkg/ cache exists, creating...
error: failed to commit transaction (conflicting files)
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/websocket-driver-0.7.5/ext/websocket-driver
C:/Ruby31-x64/bin/ruby.exe -I C:/Ruby31-x64/lib/ruby/3.1.0 -r
./siteconf20220423-17760-hpdh3z.rb extconf.rb
creating Makefile
current directory:
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/websocket-driver-0.7.5/ext/websocket-driver
make DESTDIR\= clean
bash.exe: warning: could not find /tmp, please create!
current directory:
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/websocket-driver-0.7.5/ext/websocket-driver
make DESTDIR\=
generating websocket_mask-x64-mingw-ucrt.def
bash.exe: warning: could not find /tmp, please create!
compiling websocket_mask.c
make: gcc: No such file or directory
make: *** [Makefile:246: websocket_mask.o] Error 127
make failed, exit code 2
Gem files will remain installed in
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/websocket-driver-0.7.5 for inspection.
Results logged to
C:/Ruby31-x64/lib/ruby/gems/3.1.0/extensions/x64-mingw-ucrt/3.1.0/websocket-driver-0.7.5/gem_make.out
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/ext/builder.rb:95:in `run'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/ext/builder.rb:44:in `block in make'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/ext/builder.rb:36:in `each'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/ext/builder.rb:36:in `make'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/ext/ext_conf_builder.rb:63:in `block in
build'
C:/Ruby31-x64/lib/ruby/3.1.0/tempfile.rb:317:in `open'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/ext/ext_conf_builder.rb:26:in `build'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/ext/builder.rb:161:in `build_extension'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/ext/builder.rb:195:in `block in
build_extensions'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/ext/builder.rb:192:in `each'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/ext/builder.rb:192:in `build_extensions'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/installer.rb:853:in `build_extensions'
C:/Ruby31-x64/lib/ruby/3.1.0/bundler/rubygems_gem_installer.rb:71:in
`build_extensions'
C:/Ruby31-x64/lib/ruby/3.1.0/bundler/rubygems_gem_installer.rb:28:in `install'
C:/Ruby31-x64/lib/ruby/3.1.0/bundler/source/rubygems.rb:204:in `install'
C:/Ruby31-x64/lib/ruby/3.1.0/bundler/installer/gem_installer.rb:54:in
`install'
C:/Ruby31-x64/lib/ruby/3.1.0/bundler/installer/gem_installer.rb:16:in
`install_from_spec'
C:/Ruby31-x64/lib/ruby/3.1.0/bundler/installer/parallel_installer.rb:186:in
`do_install'
C:/Ruby31-x64/lib/ruby/3.1.0/bundler/installer/parallel_installer.rb:177:in
`block in worker_pool'
C:/Ruby31-x64/lib/ruby/3.1.0/bundler/worker.rb:62:in `apply_func'
C:/Ruby31-x64/lib/ruby/3.1.0/bundler/worker.rb:57:in `block in process_queue'
C:/Ruby31-x64/lib/ruby/3.1.0/bundler/worker.rb:54:in `loop'
C:/Ruby31-x64/lib/ruby/3.1.0/bundler/worker.rb:54:in `process_queue'
C:/Ruby31-x64/lib/ruby/3.1.0/bundler/worker.rb:91:in `block (2 levels) in
create_threads'
An error occurred while installing websocket-driver (0.7.5), and Bundler cannot
continue.
In Gemfile:
rails was resolved to 7.0.2.3, which depends on
actioncable was resolved to 7.0.2.3, which depends on
websocket-driver
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bindex-0.8.1/ext/skiptrace
C:/Ruby31-x64/bin/ruby.exe -I C:/Ruby31-x64/lib/ruby/3.1.0 -r
./siteconf20220423-17760-gbyu17.rb extconf.rb
creating Makefile
current directory:
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bindex-0.8.1/ext/skiptrace
make DESTDIR\= clean
bash.exe: warning: could not find /tmp, please create!
current directory:
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bindex-0.8.1/ext/skiptrace
make DESTDIR\=
generating cruby-x64-mingw-ucrt.def
bash.exe: warning: could not find /tmp, please create!
compiling cruby.c
make: gcc: No such file or directory
make: *** [Makefile:246: cruby.o] Error 127
make failed, exit code 2
Gem files will remain installed in
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bindex-0.8.1 for inspection.
Results logged to
C:/Ruby31-x64/lib/ruby/gems/3.1.0/extensions/x64-mingw-ucrt/3.1.0/bindex-0.8.1/gem_make.out
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/ext/builder.rb:95:in `run'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/ext/builder.rb:44:in `block in make'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/ext/builder.rb:36:in `each'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/ext/builder.rb:36:in `make'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/ext/ext_conf_builder.rb:63:in `block in
build'
C:/Ruby31-x64/lib/ruby/3.1.0/tempfile.rb:317:in `open'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/ext/ext_conf_builder.rb:26:in `build'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/ext/builder.rb:161:in `build_extension'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/ext/builder.rb:195:in `block in
build_extensions'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/ext/builder.rb:192:in `each'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/ext/builder.rb:192:in `build_extensions'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/installer.rb:853:in `build_extensions'
C:/Ruby31-x64/lib/ruby/3.1.0/bundler/rubygems_gem_installer.rb:71:in
`build_extensions'
C:/Ruby31-x64/lib/ruby/3.1.0/bundler/rubygems_gem_installer.rb:28:in `install'
C:/Ruby31-x64/lib/ruby/3.1.0/bundler/source/rubygems.rb:204:in `install'
C:/Ruby31-x64/lib/ruby/3.1.0/bundler/installer/gem_installer.rb:54:in
`install'
C:/Ruby31-x64/lib/ruby/3.1.0/bundler/installer/gem_installer.rb:16:in
`install_from_spec'
C:/Ruby31-x64/lib/ruby/3.1.0/bundler/installer/parallel_installer.rb:186:in
`do_install'
C:/Ruby31-x64/lib/ruby/3.1.0/bundler/installer/parallel_installer.rb:177:in
`block in worker_pool'
C:/Ruby31-x64/lib/ruby/3.1.0/bundler/worker.rb:62:in `apply_func'
C:/Ruby31-x64/lib/ruby/3.1.0/bundler/worker.rb:57:in `block in process_queue'
C:/Ruby31-x64/lib/ruby/3.1.0/bundler/worker.rb:54:in `loop'
C:/Ruby31-x64/lib/ruby/3.1.0/bundler/worker.rb:54:in `process_queue'
C:/Ruby31-x64/lib/ruby/3.1.0/bundler/worker.rb:91:in `block (2 levels) in
create_threads'
An error occurred while installing bindex (0.8.1), and Bundler cannot continue.
In Gemfile:
web-console was resolved to 4.2.0, which depends on
bindex
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/msgpack-1.5.1/ext/msgpack
C:/Ruby31-x64/bin/ruby.exe -I C:/Ruby31-x64/lib/ruby/3.1.0 -r
./siteconf20220423-17760-8dux0s.rb extconf.rb
checking for ruby/st.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=C:/Ruby31-x64/bin/$(RUBY_BASE_NAME)
--with-ruby-dir
--without-ruby-dir
--with-ruby-include
--without-ruby-include=${ruby-dir}/include
--with-ruby-lib
--without-ruby-lib=${ruby-dir}/lib
C:/Ruby31-x64/lib/ruby/3.1.0/mkmf.rb:498:in `try_do': The compiler failed to
generate an executable file. (RuntimeError)
You have to install development tools first.
from C:/Ruby31-x64/lib/ruby/3.1.0/mkmf.rb:624:in `block in try_compile'
from C:/Ruby31-x64/lib/ruby/3.1.0/mkmf.rb:573:in `with_werror'
from C:/Ruby31-x64/lib/ruby/3.1.0/mkmf.rb:624:in `try_compile'
from C:/Ruby31-x64/lib/ruby/3.1.0/mkmf.rb:1160:in `block in have_header'
from C:/Ruby31-x64/lib/ruby/3.1.0/mkmf.rb:1007:in `block in checking_for'
from C:/Ruby31-x64/lib/ruby/3.1.0/mkmf.rb:362:in `block (2 levels) in postpone'
from C:/Ruby31-x64/lib/ruby/3.1.0/mkmf.rb:332:in `open'
from C:/Ruby31-x64/lib/ruby/3.1.0/mkmf.rb:362:in `block in postpone'
from C:/Ruby31-x64/lib/ruby/3.1.0/mkmf.rb:332:in `open'
from C:/Ruby31-x64/lib/ruby/3.1.0/mkmf.rb:358:in `postpone'
from C:/Ruby31-x64/lib/ruby/3.1.0/mkmf.rb:1006:in `checking_for'
from C:/Ruby31-x64/lib/ruby/3.1.0/mkmf.rb:1159:in `have_header'
from extconf.rb:3:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can
be found here:
C:/Ruby31-x64/lib/ruby/gems/3.1.0/extensions/x64-mingw-ucrt/3.1.0/msgpack-1.5.1/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/msgpack-1.5.1 for inspection.
Results logged to
C:/Ruby31-x64/lib/ruby/gems/3.1.0/extensions/x64-mingw-ucrt/3.1.0/msgpack-1.5.1/gem_make.out
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/ext/builder.rb:95:in `run'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/ext/ext_conf_builder.rb:47:in `block in
build'
C:/Ruby31-x64/lib/ruby/3.1.0/tempfile.rb:317:in `open'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/ext/ext_conf_builder.rb:26:in `build'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/ext/builder.rb:161:in `build_extension'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/ext/builder.rb:195:in `block in
build_extensions'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/ext/builder.rb:192:in `each'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/ext/builder.rb:192:in `build_extensions'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/installer.rb:853:in `build_extensions'
C:/Ruby31-x64/lib/ruby/3.1.0/bundler/rubygems_gem_installer.rb:71:in
`build_extensions'
C:/Ruby31-x64/lib/ruby/3.1.0/bundler/rubygems_gem_installer.rb:28:in `install'
C:/Ruby31-x64/lib/ruby/3.1.0/bundler/source/rubygems.rb:204:in `install'
C:/Ruby31-x64/lib/ruby/3.1.0/bundler/installer/gem_installer.rb:54:in
`install'
C:/Ruby31-x64/lib/ruby/3.1.0/bundler/installer/gem_installer.rb:16:in
`install_from_spec'
C:/Ruby31-x64/lib/ruby/3.1.0/bundler/installer/parallel_installer.rb:186:in
`do_install'
C:/Ruby31-x64/lib/ruby/3.1.0/bundler/installer/parallel_installer.rb:177:in
`block in worker_pool'
C:/Ruby31-x64/lib/ruby/3.1.0/bundler/worker.rb:62:in `apply_func'
C:/Ruby31-x64/lib/ruby/3.1.0/bundler/worker.rb:57:in `block in process_queue'
C:/Ruby31-x64/lib/ruby/3.1.0/bundler/worker.rb:54:in `loop'
C:/Ruby31-x64/lib/ruby/3.1.0/bundler/worker.rb:54:in `process_queue'
C:/Ruby31-x64/lib/ruby/3.1.0/bundler/worker.rb:91:in `block (2 levels) in
create_threads'
An error occurred while installing msgpack (1.5.1), and Bundler cannot continue.
In Gemfile:
bootsnap was resolved to 1.11.1, which depends on
msgpack
run bundle binstubs bundler
Could not find gem 'rails (~> 7.0.2, >= 7.0.2.3)' in locally installed gems.
rails importmap:install
C:/Ruby31-x64/lib/ruby/3.1.0/bundler/resolver.rb:269:in `block in verify_gemfile_dependencies_are_found!': Could not find gem 'rails (~> 7.0.2, >= 7.0.2.3)' in locally installed gems. (Bundler::GemNotFound)
from C:/Ruby31-x64/lib/ruby/3.1.0/bundler/resolver.rb:252:in `map!'
from C:/Ruby31-x64/lib/ruby/3.1.0/bundler/resolver.rb:252:in `verify_gemfile_dependencies_are_found!'
from C:/Ruby31-x64/lib/ruby/3.1.0/bundler/resolver.rb:48:in `start'
from C:/Ruby31-x64/lib/ruby/3.1.0/bundler/resolver.rb:23:in `resolve'
from C:/Ruby31-x64/lib/ruby/3.1.0/bundler/definition.rb:269:in `resolve'
from C:/Ruby31-x64/lib/ruby/3.1.0/bundler/definition.rb:468:in `materialize'
from C:/Ruby31-x64/lib/ruby/3.1.0/bundler/definition.rb:190:in `specs'
from C:/Ruby31-x64/lib/ruby/3.1.0/bundler/definition.rb:238:in `specs_for'
from C:/Ruby31-x64/lib/ruby/3.1.0/bundler/runtime.rb:18:in `setup'
from C:/Ruby31-x64/lib/ruby/3.1.0/bundler.rb:151:in `setup'
from C:/Ruby31-x64/lib/ruby/3.1.0/bundler/setup.rb:20:in `block in <top (required)>'
from C:/Ruby31-x64/lib/ruby/3.1.0/bundler/ui/shell.rb:136:in `with_level'
from C:/Ruby31-x64/lib/ruby/3.1.0/bundler/ui/shell.rb:88:in `silence'
from C:/Ruby31-x64/lib/ruby/3.1.0/bundler/setup.rb:20:in `<top (required)>'
from <internal:C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from <internal:C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from C:/testrails/blog/config/boot.rb:3:in `<top (required)>'
from bin/rails:3:in `require_relative'
from bin/rails:3:in `<main>'
rails turbo:install stimulus:install
C:/Ruby31-x64/lib/ruby/3.1.0/bundler/resolver.rb:269:in `block in verify_gemfile_dependencies_are_found!': Could not find gem 'rails (~> 7.0.2, >= 7.0.2.3)' in locally installed gems. (Bundler::GemNotFound)
from C:/Ruby31-x64/lib/ruby/3.1.0/bundler/resolver.rb:252:in `map!'
from C:/Ruby31-x64/lib/ruby/3.1.0/bundler/resolver.rb:252:in `verify_gemfile_dependencies_are_found!'
from C:/Ruby31-x64/lib/ruby/3.1.0/bundler/resolver.rb:48:in `start'
from C:/Ruby31-x64/lib/ruby/3.1.0/bundler/resolver.rb:23:in `resolve'
from C:/Ruby31-x64/lib/ruby/3.1.0/bundler/definition.rb:269:in `resolve'
from C:/Ruby31-x64/lib/ruby/3.1.0/bundler/definition.rb:468:in `materialize'
from C:/Ruby31-x64/lib/ruby/3.1.0/bundler/definition.rb:190:in `specs'
from C:/Ruby31-x64/lib/ruby/3.1.0/bundler/definition.rb:238:in `specs_for'
from C:/Ruby31-x64/lib/ruby/3.1.0/bundler/runtime.rb:18:in `setup'
from C:/Ruby31-x64/lib/ruby/3.1.0/bundler.rb:151:in `setup'
from C:/Ruby31-x64/lib/ruby/3.1.0/bundler/setup.rb:20:in `block in <top (required)>'
from C:/Ruby31-x64/lib/ruby/3.1.0/bundler/ui/shell.rb:136:in `with_level'
from C:/Ruby31-x64/lib/ruby/3.1.0/bundler/ui/shell.rb:88:in `silence'
from C:/Ruby31-x64/lib/ruby/3.1.0/bundler/setup.rb:20:in `<top (required)>'
from <internal:C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from <internal:C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from C:/testrails/blog/config/boot.rb:3:in `<top (required)>'
from bin/rails:3:in `require_relative'
from bin/rails:3:in `<main>'
This is the mkmf.log
PATH=".;C:/Ruby31-x64/lib;C:\Ruby31-x64\bin;C:\Ruby31-x64\msys64\mingw64\bin;C:\Ruby31-x64\msys64\usr\bin;C:\Users\oohpi\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\local\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Users\oohpi\bin;C:\Program Files\Eclipse Adoptium\jdk-17.0.2.8-hotspot\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files\Git\cmd;C:\Program Files (x86)\Calibre2;C:\Program Files\nodejs;C:\Ruby31-x64\bin;C:\RailsInstaller\Git\cmd;C:\RailsInstaller\Ruby2.3.3\bin;C:\Users\oohpi\AppData\Local\Programs\Python\Python310\Scripts;C:\Users\oohpi\AppData\Local\Programs\Python\Python310;C:\Users\oohpi\AppData\Local\Microsoft\WindowsApps;C:\Users\oohpi\AppData\Local\Programs\Microsoft VS Code\bin;C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.3.1\bin;C:\Users\oohpi\AppData\Local\GitHubDesktop\bin;C:\Users\oohpi\AppData\Roaming\npm;C:\Program Files\Git\usr\bin\vendor_perl;C:\Program Files\Git\usr\bin\core_perl" "gcc -o conftest.exe -IC:/Ruby31-x64/include/ruby-3.1.0/x64-mingw-ucrt -IC:/Ruby31-x64/include/ruby-3.1.0/ruby/backward -IC:/Ruby31-x64/include/ruby-3.1.0 -I. -D__USE_MINGW_ANSI_STDIO=1 -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0600 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64 -O3 -fno-fast-math -fstack-protector-strong conftest.c -L. -LC:/Ruby31-x64/lib -L. -pipe -s -fstack-protector-strong -Wl,--no-as-needed -m64 -lx64-ucrt-ruby310 -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi -lbcrypt "
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <winsock2.h>
4: #include <windows.h>
5: int main(int argc, char **argv)
6: {
7: return !!argv[argc];
8: }
/* end */
I think the problem is with the websocket-driver gem? I've been trying to fix this for a long time and google hasn't been helpful. I have no idea what I'm doing any help would be appreciated.
jeudi 21 avril 2022
Ruby : Cannot load such file --ruby2d (LoadError)
I'm new to Ruby,Writing some code to make a game,so using ruby2d library.
Got an error while writing some basic code.
Help me out Folks.
require 'ruby2d'
set background: Navy
show
Image of the error coming up in vscode terminal
mercredi 20 avril 2022
Returning to functions but having to access arrays created only on main, how to?
I'm making a very simple code here to practice with Ruby and going to implement a simple "client, product, sell" interface
def menuinicial
print "1 - Cliente
2 - Produto
3 - Venda
0 - Sair do programa
insira o código de manipulação desejado: ";
end
here is the initial menu
def manipclientes
while true
puts "\n1 - Adicionar cliente"
puts "2 - Visualizar clientes cadastrados"
puts "3 - Editar cliente"
puts "4 - Remover cliente"
puts "0 - Retornar ao menu anterior"
print "\nInsira a opção desejada: "
escolha = gets.chomp
return if escolha == "0"
if escolha == "1" # "Adicionar cliente"
print "\ninsira o nome do cliente: "
nome = gets.chomp
print "\ninsira o endereço do cliente: "
rua = gets.chomp
print "\ninsira o RG do cliente: "
rg = gets.chomp
print "\ninsira a data de nascimento do cliente( Ano, mês, dia): "
ano = gets.chomp
mes = gets.chomp
dia = gets.chomp
data = Time.new(ano.to_i, mes.to_i, dia.to_i)
a = Cliente.new(nome, rua, rg, data)
clientes.push(a) #adicionando a ao array
end
here is part of the code that is having issue, just right when I try to use the "Client.new" returns me the error
"in manipclientes': undefined local variable or method `clientes' for main:Object (NameError)"
and below there's the main code partially ready to go
# main
while true
menuinicial
init = gets.chomp
break if init == "0"
manipclientes if init == "1"
manipprodutos if init == "2"
end
I can get the code working when I don't place it in "functions" but then I can't return to the initial menu (I've made a post right here)
mardi 19 avril 2022
How can I render multiple resources in one API request?
This is what I am trying to achieve
"Add a RESTful, read-only API to allow consumers to retrieve Questions with Answers as JSON (no need to retrieve Answers on their own). The response should include Answers inside their Question as well as include the id and name of the Question and Answer users."
So far I have my controllers set up as follows:
class Api::V1::UsersController < ApplicationController
def index
@users = User.all
render json: @users
end
def show
@user = User.find(params[:id])
render json: @user
end
end
class Api::V1::QuestionsController < ApplicationController
def index
@questions = Question.where(share: true)
render json: @questions
end
end
class Api::V1::AnswersController < ApplicationController
def index
@answers = Answer.all
render json: @answers
end
end
And my routes are set up like this however I'm sure this is not correct for what I want to achieve
Rails.application.routes.draw do
namespace :api do namespace :v1 do resources :questions do resources :answers do resources :users end end end end
root 'welcome#index'
get 'welcome/index' end
Any help would be appreciated
How to add double quotes to elements inside a array in Ruby
I am very new to the Ruby, I have array and I want to add double quotes to all alpha-numeric elements
array I have: a = [a255b78, wr356672]
Array i required: a =["a255b78", "wr356672"]
Is there any direct way to do this?
session.inspect output with propper indentation in rails
Using p session.inspect
outputs a single line. I want to add a html-container in my application view, always showing what's inside the session. But this should be properly formatted with indentations and breaks. Is there a way to achieve this?
In PHP, e. g., you can wrap the output of $_SESSION
in a <pre>
-tag and it will automatically be properly formatted.
lundi 18 avril 2022
Query on JSONB column to extract records between 2 dates
I am struggling to write a query in a Rails model which will retrieve all records with the date between two dates( dynamic dates from UI input).
The column is a jsonB column looking like this:
"170"=>[{"name"=>"Conflict Date/Time", "value"=>"2022-04-14 14:51:29", "valueUTC"=>"2022-04-14 13:51:29"}],
This record should be a valid one returned for a search with start_date: "2022-04-12 13:22:55" end_date: "2022-04-18 16:11:22".
What i got so far? This query:
where("short_response->>'#{item_id}' ~* ?", "\"value\": BETWEEN #{start_date} AND #{end_date}")
Thank you! Any help will be appreciated.
jeudi 14 avril 2022
Finding a weird symbol in Capybara
I'm currently trying to find a symbol on a page. I have the HTML tag and the find method that I'm using. However it's not able to find this symbol. I'm not sure what I'm doing wrong to do so.
<div class="ui-grid-selection-row-header-buttons ui-grid-icon-ok clickable bg-pristine bg-valid bg-scope bg-not-empty bg-touched" bg-class="{'ui-grid-row-selected': row.isSelected}" tabindex="0" bg-click="selectButtonClick(row, $event)" bg-keydown="selectButtonKeyDown(row, $event)" role="checkbox" bg-model="row.isSelected" aria-checked="true" aria-invalid="false"> </div>
As you can see this is a weird html tag. I'm trying to avoid full xpath if possible.
Here is what I"m doing.
find(:css, "ui-grid-selection-row-header-buttons[button = 'selectButtonClick']")
mardi 12 avril 2022
Why 0.0 throws can't be blank?
If I work with this code, and I enter 0.0 (or 0), why does it throw xyzzy can't be blank
validates :xyzzy, numericality: { greater_than_or_equal_to: 0, less_than: 100 }, allow_blank: true
Please help!
samedi 9 avril 2022
Pls I need explanation of this code snippet written in Haml
Pls I don't know anything about Haml just know that it is a markup language predominantly used with Ruby.
So I am trying to do animation with gsap and I saw the code below on codepen
- w = 1240
- h = 874
.demo-wrapper
%header.df.aic.jcc
%div
%h1 ScrollTrigger
%h2 demo
%section.demo-text
.wrapper.text
ABCDEFGHIJKLMNOPQRSTUVWXYZ
- (1..4).each do |i|
%section.demo-gallery
%ul.wrapper
- (1..rand(3..4)).each do |i|
%li
%img{:src=>"https://source.unsplash.com/random/#{w}x#{h}?sig=#{rand(0..206)}",
:width => w, :height => h}
%section.demo-text
.wrapper.text
ABCDEFGHIJKLMNOPQRSTUVWXYZ
%footer.df.aic.jcc
%p Images from <a href="https://unsplash.com/">Unsplash</a>
Please I need an explanation of this section of the code
- (1..4).each do |i|
%section.demo-gallery
%ul.wrapper
- (1..rand(3..4)).each do |i|
%li
%img{:src=>"https://source.unsplash.com/random/#{w}x#{h}?sig=#{rand(0..206)}",
:width => w, :height => h}
Ruby on Rails - Generate POST request without refreshing the page
I am creating an e-commerce website with Ruby on Rails and there is something bothering me.
I have a product card with a link. If the user clicks the link, the product goes into the cart. I used remote: true
so that it allows to generate the POST request without refreshing the page:
<%= link_to order_items_path(product_id: product), remote: true, method: :post do %>
<i class="fas fa-shopping-cart"></i>
<% end %>
But it always ends up refreshing the page and scrolling to the top of the page. Am I missing something?
And if it is not like this how it works, how could I make it do what I want?
Just for reference, the link goes to the OrderItemsController#create
:
def create
@order = OrderItem.generate_order(current_user)
if order_items_params
@order_item = OrderItem.new(order_items_params)
else
@order_item = OrderItem.new(quantity: 1, product_id: params[:product_id])
end
@order_item.order = @order
authorize @order_item
if @order_item.save
redirect_to edit_order_path(@order)
else
redirect_to root_path, notice: "Product not ordered, please try again"
end
end
Thanks!
vendredi 8 avril 2022
How to make a subtraction between 2 records from the same column using rails?
Hi Stackoverflow team.
I'm using ruby on rails and i'm trying to find the code to make a subtraction between 2 records from the same column using rails.
I have the following table
customers
id num_hid num_oxi
1 1 2
2 3 4
3 5 6
4 7 8
I'm trying to get this result
@result = last_num_hid_id_4 - last_num_hid_id_3
//calcultion is: 7-5 = 2
i did this code but this displays the last 2 records in array
<% @customers.each.last(2) do |customer|%> %>
<%= customer.num_hid %>
<% end %>
i tried this code but is only showing the last record
@last_customer =Customer.all.last
@last.num_hid
Can somebody help me with this issue?
I will appreciate all your comments.
Thanks in advance.
jeudi 7 avril 2022
Application error in heroku after successfully deployed - Ruby on Rails 7
Error detail is:
An error occurred in the application and your page could not be served.
Here is logs details by command heroku logs --tail
2022-04-07T06:14:27.384637+00:00 app[web.1]: from config.ru:3:in require_relative' 2022-04-07T06:14:27.384637+00:00 app[web.1]: from config.ru:3:in
block in ' 2022-04-07T06:14:27.384644+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/rack-2.2.3/lib/rack/builder.rb:116:in eval' 2022-04-07T06:14:27.384644+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/rack-2.2.3/lib/rack/builder.rb:116:in
new_from_string' 2022-04-07T06:14:27.384651+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/rack-2.2.3/lib/rack/builder.rb:105:in load_file' 2022-04-07T06:14:27.384652+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/rack-2.2.3/lib/rack/builder.rb:66:in
parse_file' 2022-04-07T06:14:27.384654+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/rack-2.2.3/lib/rack/server.rb:349:in build_app_and_options_from_config' 2022-04-07T06:14:27.384661+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/rack-2.2.3/lib/rack/server.rb:249:in
app' 2022-04-07T06:14:27.384663+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/rack-2.2.3/lib/rack/server.rb:422:in wrapped_app' 2022-04-07T06:14:27.384664+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/rack-2.2.3/lib/rack/server.rb:312:in
block in start' 2022-04-07T06:14:27.384671+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/rack-2.2.3/lib/rack/server.rb:379:in handle_profiling' 2022-04-07T06:14:27.384672+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/rack-2.2.3/lib/rack/server.rb:311:in
start' 2022-04-07T06:14:27.384679+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/railties-7.0.2.3/lib/rails/commands/server/server_command.rb:38:in start' 2022-04-07T06:14:27.384679+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/railties-7.0.2.3/lib/rails/commands/server/server_command.rb:143:in
block in perform' 2022-04-07T06:14:27.384687+00:00 app[web.1]: from internal:kernel:90:in tap' 2022-04-07T06:14:27.384687+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/railties-7.0.2.3/lib/rails/commands/server/server_command.rb:134:in
perform' 2022-04-07T06:14:27.384689+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/thor-1.2.1/lib/thor/command.rb:27:in run' 2022-04-07T06:14:27.384696+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in
invoke_command' 2022-04-07T06:14:27.384696+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/thor-1.2.1/lib/thor.rb:392:in dispatch' 2022-04-07T06:14:27.384703+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/railties-7.0.2.3/lib/rails/command/base.rb:87:in
perform' 2022-04-07T06:14:27.384703+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/railties-7.0.2.3/lib/rails/command.rb:48:in invoke' 2022-04-07T06:14:27.384711+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/railties-7.0.2.3/lib/rails/commands.rb:18:in
' 2022-04-07T06:14:27.384711+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in require' 2022-04-07T06:14:27.384718+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in
require' 2022-04-07T06:14:27.384719+00:00 app[web.1]: from bin/rails:4:in `' 2022-04-07T06:14:27.517957+00:00 heroku[web.1]: Process exited with status 1 2022-04-07T06:14:27.751744+00:00 heroku[web.1]: State changed from starting to crashed
mercredi 6 avril 2022
Finding a button in Capybara
I'm trying to find this specific button. I've tried using find button in capybara to do this but I'm unable to.
find(:button, 'Open Cow menu').click
HTML Tag
<button class="cd-icon-button cd-button cd-irx-cyan-theme" type="button" ng-transclude="" aria-label="Open Cow menu" ng-click="$mdMenu.open($event)" aria-haspopup="true" aria-expanded="false" aria-owns="menu_container_1">
<i class="fa fa-ellipsis-h" aria-hidden="true"></i>
</button>
I'm sure there is a easier way of doing this.
samedi 2 avril 2022
Devise + Patreon OAuth in Ruby on Rails
I have implemented the devise+patreon gem in my Rails application without issues. Now, devise requires an email/password by default when creating a User, but Patreon just uses the oauth integration.
I am wondering, what is the proper strategy to use so that I can migrate the Patreon Oauth users as Devise users, without having to set dummy passwords/emails to allow for validation to go through. I still want to eventually allow users to register via Devise natively, as well as through Patreon.
Is there maybe a known strategy/gem/addition for devise that I may have missed that can easily achieve that?
vendredi 1 avril 2022
Extracting images from multiple PDF files using hexapdf - hexapdf no such file or directory @ rb_sysopen
I'm in my master thesis and I have to extract images from about 500 pdf files, some people recommended hexapdf to me for this. I was able to install Ruby and hexapdf and now I'm kinda stuck getting the images out of the pdf's since I don't have a coding background. Any tips? Thanks in advance.
I tried using the basic command for only one pdf to see what happened by using 'hexapdf images' followed by the pdf name but the result was 'no such file or directory @ rb_sysopen'.