vendredi 29 janvier 2021

Custom association in Rails 3.2 to preload query

I am using Rails 3.2.13 and Ruby 2.0.0.

I want to preload an association with conditions but when I write association (order_last_email ) it gives an error.

wrong number of arguments (1 for 0)

Here is a sample of the code.

class Company < AbstractModel
 has_many :emails

 # extra association
 has_one :order_last_email, -> { recent.last }, class_name: "Email"  
end

jeudi 28 janvier 2021

Cron job and whenever gem

I'm new to rails I am trying to implement cron jon in my app this is my schedule.rb

set :environment, "development"
set :output, "log/cron.log"
every 2.minutes do
    rake 'batch:send_digest_email'
end

this is lib/tasks/email_task.rake

namespace :batch do
  desc 'send digest email'
  task send_digest_email: :environment do
    # ... set options if any
    user = User.last
    # @user.each do |user|
      ExampleMailer.sample_email(user).deliver!
    # end
  end
end

email functionality is working correctly. Implementing using cron jobs is not working. I have run the bundle exec whenever command. This is the logfile

/usr/lib/ruby/vendor_ruby/rubygems/defaults/operating_system.rb:50:in `<class:Specification>': undefined method `rubyforge_project=' for class `Gem::Specification' (NameError)
    from /usr/lib/ruby/vendor_ruby/rubygems/defaults/operating_system.rb:49:in `<top (required)>'
    from /snap/ruby/201/lib/ruby/3.0.0/rubygems.rb:1348:in `require'
    from /snap/ruby/201/lib/ruby/3.0.0/rubygems.rb:1348:in `<top (required)>'
    from <internal:gem_prelude>:2:in `require'
    from <internal:gem_prelude>:2:in `<internal:gem_prelude>'

How to read the xml node and replace other node in ruby

I have a below xml. I need to read the node Bus and replace Transport to ROAD WAYS and Flight to Air Ways

 <Field>
  <Name>Bus</Name>
  <Value>Volvo</Value>
  <Desc>Transport</Desc>
</Field>
<Field>
  <Name>Flight</Name>
  <Value>Air-Bus</Value>
  <Desc>Transport</Desc>
</Field>

lundi 25 janvier 2021

Active Directory user creation with LDAP using Ruby on Rails

I am trying to create a new user from the create.controller.rb

 dn = 'cn= Test1 test1111'+ ',ou=Real-Testing,ou=Users,ou=DE,ou=xyz,dc=xyz,dc=intra'

ldap = LDAP.new
ldap.add_user_record(dn, attributes)

the lib/ldap.rb code is as follows as

def add_user_record(dn, attributes)
    @ldap.add( :dn => dn, :attributes => attributes )
  end

However,I am receiving the following error NoMethodError (undefined method `map' for 18400597803079440689678002902069631524796887079072566:Integer Did you mean? tap):

Can anyone help me fix this error?

Thanks

samedi 23 janvier 2021

Issue on Installing Ruby On Rails for specific version on Ubuntu 18.04

I had installed Ruby at the version of 2.7.0 and Gem at the version of 3.1.2 when I used the command " gem install rails " it shows an error like this..

ERROR: Loading command: install (LoadError) cannot load such file -- zlib ERROR: While executing gem ... (NoMethodError) undefined method `invoke_with_build_args' for nil:NilClass

Help me to find it..

mercredi 20 janvier 2021

Unable To Install 'therubyracer v0.12.3' gem in M1 Macbook Pro

I am using M1 Macbook Pro and wants to install therubyracer and libv8 for a rails webapp. But I am unable to do so because of the errors described below. There are several solutions available on the internet but none of them is working for me.

Operating System: macOS Big Sur v11.1.

It would be very helpful if someone can help me with this.

Log:

❯ ruby -v
ruby 2.5.5p157 (2019-03-15 revision 67260) [-darwin20]
❯ bundle -v
Bundler version 1.17.3
❯ brew -v
Homebrew 2.7.5
Homebrew/homebrew-core (git revision e04a30; last commit 2021-01-20)
Homebrew/homebrew-cask (git revision d128de; last commit 2021-01-20)
❯ uname -a
Darwin Vaibhavs-MacBook-Pro.local 20.2.0 Darwin Kernel Version 20.2.0: Wed Dec  2 20:40:21 PST 2020; root:xnu-7195.60.75~1/RELEASE_ARM64_T8101 arm64


❯ brew search v8
==> Formulae
v8 ✔                                                                 v8@3.15
==> Casks
amitv87-pip


❯ brew install v8@3.15
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 2 taps (homebrew/core and homebrew/cask).
==> Updated Formulae
Updated 3 formulae.
==> Updated Casks
Updated 3 casks.

Error: v8@3.15: no bottle available!
You can try to install from source with:
  brew install --build-from-source v8@3.15
Please note building from source is unsupported. You will encounter build
failures with some formulae. If you experience any issues please create pull
requests instead of asking for help on Homebrew's GitHub, Twitter or any other
official channels.


❯ brew install --build-from-source v8@3.15
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/cask).
==> Updated Casks
Updated 1 cask.

==> Cloning https://chromium.googlesource.com/external/gyp.git
Updating /Users/vaibhavgupta/Library/Caches/Homebrew/v8@3.15--gyp--git
==> Checking out revision f7bc250ccc4d619a1cf238db87e5979f89ff36d7
HEAD is now at f7bc250c Make gyp/win32 compatible with upstream ninja.
HEAD is now at f7bc250c Make gyp/win32 compatible with upstream ninja.
==> Downloading https://github.com/v8/v8-git-mirror/archive/3.15.11.18.tar.gz
Already downloaded: /Users/vaibhavgupta/Library/Caches/Homebrew/downloads/26ea05158c6c6ebb67cc42075858df9a986f9c615513933b1e62bb707f707854--v8-3.15.11.18.tar.gz
==> make native -j8 library=shared snapshot=on console=readline
Last 15 lines from /Users/vaibhavgupta/Library/Logs/Homebrew/v8@3.15/01.make:
Atomic32 Acquire_Load(volatile const Atomic32* ptr);
         ^
In file included from ../src/conversions.cc:32:
In file included from ../src/conversions-inl.h:42:
In file included from ../src/platform.h:100:
In file included from ../src/lazy-instance.h:94:
../src/once.h:115:7: error: no matching function for call to 'Acquire_Load'
  if (Acquire_Load(once) != ONCE_STATE_DONE) {
      ^~~~~~~~~~~~
../src/atomicops.h:125:10: note: candidate function not viable: no known conversion from 'v8::internal::OnceType *' (aka 'long *') to 'const volatile v8::internal::Atomic32 *' (aka 'const volatile int *') for 1st argument
Atomic32 Acquire_Load(volatile const Atomic32* ptr);
         ^
5 errors generated.
make[1]: *** [/private/tmp/v8-3.15-20210120-4211-1soh8ig/v8-3.15.11.18/out/native/obj.target/preparser_lib/src/conversions.o] Error 1
make: *** [native] Error 2

Do not report this issue to Homebrew/brew or Homebrew/core!


❯ brew install v8
==> Downloading https://homebrew.bintray.com/bottles/v8-8.8.278.14.arm64_big_sur.bottle.tar.gz
Already downloaded: /Users/vaibhavgupta/Library/Caches/Homebrew/downloads/457adba5b4da5d7cb7d6d896218ebc5d8f1453782321e97a3df424f4a4e8a821--v8-8.8.278.14.arm64_big_sur.bottle.tar.gz
==> Pouring v8-8.8.278.14.arm64_big_sur.bottle.tar.gz
🍺  /opt/homebrew/Cellar/v8/8.8.278.14: 80 files, 39.9MB


❯ brew --prefix v8
/opt/homebrew/opt/v8


❯ gem install libv8 -v '3.16.14.19'
Fetching libv8-3.16.14.19.gem
Building native extensions. This could take a while...
ERROR:  Error installing libv8:
    ERROR: Failed to build gem native extension.

    current directory: /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19/ext/libv8
/Users/vaibhavgupta/.rvm/rubies/ruby-2.5.5/bin/ruby -I /Users/vaibhavgupta/.rvm/rubies/ruby-2.5.5/lib/ruby/site_ruby/2.5.0 -r ./siteconf20210120-6051-11xeqcl.rb extconf.rb
creating Makefile
Applying /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19/patches/disable-building-tests.patch
Applying /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19/patches/disable-werror-on-osx.patch
Applying /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19/patches/disable-xcode-debugging.patch
Applying /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19/patches/do-not-imply-vfp3-and-armv7.patch
Applying /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19/patches/do-not-use-MAP_NORESERVE-on-freebsd.patch
Applying /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19/patches/do-not-use-vfp2.patch
Applying /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19/patches/fPIC-for-static.patch
Compiling v8 for arm
Using python 2.7.16
Using compiler: c++ (clang version 12.0.0)
Unable to find a compiler officially supported by v8.
It is recommended to use GCC v4.4 or higher
Beginning compilation. This will take some time.
Building v8 with env CXX=c++ LINK=c++  /usr/bin/make arm.release vfp2=off vfp3=on hardfp=on ARFLAGS.target=crs werror=no
GYP_GENERATORS=make \
    build/gyp/gyp --generator-output="out" build/all.gyp \
                  -Ibuild/standalone.gypi --depth=. \
                  -Dv8_target_arch=arm \
                  -S.arm  -Dv8_enable_backtrace=1 -Dv8_can_use_vfp2_instructions=false -Dv8_can_use_vfp3_instructions=true -Darm_fpu=vfpv3 -Dwerror='' -Dv8_use_arm_eabi_hardfloat=true
  CXX(target) /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19/vendor/v8/out/arm.release/obj.target/preparser_lib/src/allocation.o
clang: warning: include path for libstdc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
In file included from ../src/allocation.cc:33:
../src/utils.h:33:10: fatal error: 'climits' file not found
#include <climits>
         ^~~~~~~~~
1 error generated.
make[1]: *** [/Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19/vendor/v8/out/arm.release/obj.target/preparser_lib/src/allocation.o] Error 1
make: *** [arm.release] Error 2
/Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19/ext/libv8/location.rb:36:in `block in verify_installation!': libv8 did not install properly, expected binary v8 archive '/Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19/vendor/v8/out/arm.release/obj.target/tools/gyp/libv8_base.a'to exist, but it was not found (Libv8::Location::Vendor::ArchiveNotFound)
    from /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19/ext/libv8/location.rb:35:in `each'
    from /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19/ext/libv8/location.rb:35:in `verify_installation!'
    from /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19/ext/libv8/location.rb:26:in `install!'
    from extconf.rb:7:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19 for inspection.
Results logged to /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/extensions/-darwin-20/2.5.0/libv8-3.16.14.19/gem_make.out


❯ gem install libv8 -v '3.16.14.19' -- --with-system-v8
Building native extensions with: '--with-system-v8'
This could take a while...
Successfully installed libv8-3.16.14.19
Parsing documentation for libv8-3.16.14.19
Installing ri documentation for libv8-3.16.14.19
Done installing documentation for libv8 after 0 seconds
1 gem installed


❯ gem install therubyracer -v '0.12.3'
Building native extensions. This could take a while...
ERROR:  Error installing therubyracer:
    ERROR: Failed to build gem native extension.

    current directory: /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/therubyracer-0.12.3/ext/v8
/Users/vaibhavgupta/.rvm/rubies/ruby-2.5.5/bin/ruby -I /Users/vaibhavgupta/.rvm/rubies/ruby-2.5.5/lib/ruby/site_ruby/2.5.0 -r ./siteconf20210120-6195-ojni3j.rb extconf.rb
checking for -lpthread... yes
checking for -lobjc... yes
checking for v8.h... no
*** 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
    --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=/Users/vaibhavgupta/.rvm/rubies/ruby-2.5.5/bin/$(RUBY_BASE_NAME)
    --with-pthreadlib
    --without-pthreadlib
    --with-objclib
    --without-objclib
    --enable-debug
    --disable-debug
    --with-v8-dir
    --without-v8-dir
    --with-v8-include
    --without-v8-include=${v8-dir}/include
    --with-v8-lib
    --without-v8-lib=${v8-dir}/lib
/Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19/ext/libv8/location.rb:50:in `configure': By using --with-system-v8, you have chosen to use the version  (Libv8::Location::System::NotFoundError)
of V8 found on your system and *not* the one that is bundled with
the libv8 rubygem.

However, your system version of v8 could not be located.

Please make sure your system version of v8 that is compatible
with 3.16.14.19 installed. You may need to use the
--with-v8-dir option if it is installed in a non-standard location
    from /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19/lib/libv8.rb:7:in `configure_makefile'
    from extconf.rb:32:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/extensions/-darwin-20/2.5.0/therubyracer-0.12.3/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/therubyracer-0.12.3 for inspection.
Results logged to /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/extensions/-darwin-20/2.5.0/therubyracer-0.12.3/gem_make.out


❯ gem install therubyracer -v '0.12.3' -- --with-v8-dir=/opt/homebrew/opt/v8
Building native extensions with: '--with-v8-dir=/opt/homebrew/opt/v8'
This could take a while...
ERROR:  Error installing therubyracer:
    ERROR: Failed to build gem native extension.

    current directory: /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/therubyracer-0.12.3/ext/v8
/Users/vaibhavgupta/.rvm/rubies/ruby-2.5.5/bin/ruby -I /Users/vaibhavgupta/.rvm/rubies/ruby-2.5.5/lib/ruby/site_ruby/2.5.0 -r ./siteconf20210120-6214-10f7ru2.rb extconf.rb --with-v8-dir\=/opt/homebrew/opt/v8
checking for -lpthread... yes
checking for -lobjc... yes
checking for v8.h... no
*** 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
    --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=/Users/vaibhavgupta/.rvm/rubies/ruby-2.5.5/bin/$(RUBY_BASE_NAME)
    --with-pthreadlib
    --without-pthreadlib
    --with-objclib
    --without-objclib
    --enable-debug
    --disable-debug
    --with-v8-dir
    --with-v8-include
    --without-v8-include=${v8-dir}/include
    --with-v8-lib
    --without-v8-lib=${v8-dir}/lib
/Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19/ext/libv8/location.rb:50:in `configure': By using --with-system-v8, you have chosen to use the version  (Libv8::Location::System::NotFoundError)
of V8 found on your system and *not* the one that is bundled with
the libv8 rubygem.

However, your system version of v8 could not be located.

Please make sure your system version of v8 that is compatible
with 3.16.14.19 installed. You may need to use the
--with-v8-dir option if it is installed in a non-standard location
    from /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19/lib/libv8.rb:7:in `configure_makefile'
    from extconf.rb:32:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/extensions/-darwin-20/2.5.0/therubyracer-0.12.3/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/therubyracer-0.12.3 for inspection.
Results logged to /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/extensions/-darwin-20/2.5.0/therubyracer-0.12.3/gem_make.out


❯ gem install therubyracer -v '0.12.3' -- --with-v8-dir=/opt/homebrew/opt/v8/libexec/
Building native extensions with: '--with-v8-dir=/opt/homebrew/opt/v8/libexec/'
This could take a while...
ERROR:  Error installing therubyracer:
    ERROR: Failed to build gem native extension.

    current directory: /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/therubyracer-0.12.3/ext/v8
/Users/vaibhavgupta/.rvm/rubies/ruby-2.5.5/bin/ruby -I /Users/vaibhavgupta/.rvm/rubies/ruby-2.5.5/lib/ruby/site_ruby/2.5.0 -r ./siteconf20210120-6235-1hlxxtd.rb extconf.rb --with-v8-dir\=/opt/homebrew/opt/v8/libexec/
checking for -lpthread... yes
checking for -lobjc... yes
checking for v8.h... no
*** 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
    --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=/Users/vaibhavgupta/.rvm/rubies/ruby-2.5.5/bin/$(RUBY_BASE_NAME)
    --with-pthreadlib
    --without-pthreadlib
    --with-objclib
    --without-objclib
    --enable-debug
    --disable-debug
    --with-v8-dir
    --with-v8-include
    --without-v8-include=${v8-dir}/include
    --with-v8-lib
    --without-v8-lib=${v8-dir}/lib
/Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19/ext/libv8/location.rb:50:in `configure': By using --with-system-v8, you have chosen to use the version  (Libv8::Location::System::NotFoundError)
of V8 found on your system and *not* the one that is bundled with
the libv8 rubygem.

However, your system version of v8 could not be located.

Please make sure your system version of v8 that is compatible
with 3.16.14.19 installed. You may need to use the
--with-v8-dir option if it is installed in a non-standard location
    from /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/libv8-3.16.14.19/lib/libv8.rb:7:in `configure_makefile'
    from extconf.rb:32:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/extensions/-darwin-20/2.5.0/therubyracer-0.12.3/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/gems/therubyracer-0.12.3 for inspection.
Results logged to /Users/vaibhavgupta/.rvm/gems/ruby-2.5.5/extensions/-darwin-20/2.5.0/therubyracer-0.12.3/gem_make.out

mardi 19 janvier 2021

Cron and Actionmailer in rails. Unable to use wherever gem

I am trying to schedule a mail to be sent at a particular time every day. I have set up the action mailer in my project. It is working. Now I am trying to use cron and whenever gem.

This is my controller.

def create
    @user = User.new(user_params)

    respond_to do |format|
      if @user.save
        ExampleMailer.sample_email(@user).deliver

        format.html { redirect_to @user, notice: 'User was successfully created.' }
        format.json { render :show, status: :created, location: @user }
      else
        format.html { render :new }
        format.json { render json: @user.errors, status: :unprocessable_entity }
      end
    end
  end

This is my mailer

class ExampleMailer < ApplicationMailer
    default from: "from@example.com"
    def sample_email(user)
        @user = user
        mail(to: @user.email, subject: 'This mail is sent by suhasmv')
      end
    
end

This is schedule.rb

set :environment, "development"

every 3.minutes do
    rake 'send_digest_email'
end

this is my task


desc 'send digest email'
task send_digest_email: :environment do
  # ... set options if any
  ExampleMailer.sample_email(User.last).deliver!

end

I tried to create a tasks. But couldn't set it up.

Could anyone let me know.

Thank you in advance

Ruby model with products and sum of them

I need to know how to create a Ruby application with 3 Views, 2 models and controllers. Its about A company and articles with amount of pieces of an article and a sum of all prices. This should all be in a table. I would be creating this with Ruby on Rails. enter image description here

lundi 18 janvier 2021

Is there a way to solve: `initialize': Address already in use - bind(2) for "127.0.0.1" port 3000 (Errno::EADDRINUSE)?

CHECK THE ERROR AND THE COMMANDS I RUN AT THE END OF IT

=> Booting Puma => Rails 6.0.3.4 application starting in development => Run rails server --help for more startup options Puma starting in single mode...

  • Version 4.3.6 (ruby 2.6.6-p146), codename: Mysterious Traveller
  • Min threads: 5, max threads: 5
  • Environment: development Exiting Traceback (most recent call last): 44: from ./bin/rails:3:in <main>' 43: from ./bin/rails:3:in load' 42: from /home/mvmarco/code/mvmarco/portfolio/bin/spring:15:in <top (required)>' 41: from /home/mvmarco/.rbenv/versions/2.6.6/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in require' 40: from /home/mvmarco/.rbenv/versions/2.6.6/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in require' 39: from /home/mvmarco/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/spring-2.1.1/lib/spring/binstub.rb:11:in <top (required)>' 38: from /home/mvmarco/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/spring-2.1.1/lib/spring/binstub.rb:11:in load' 37: from /home/mvmarco/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/spring-2.1.1/bin/spring:49:in <top (required)>' 36: from /home/mvmarco/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/spring-2.1.1/lib/spring/client.rb:30:in run' 35: from /home/mvmarco/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/spring-2.1.1/lib/spring/client/command.rb:7:in call' 34: from /home/mvmarco/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/spring-2.1.1/lib/spring/client/rails.rb:28:in call' 33: from /home/mvmarco/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/spring-2.1.1/lib/spring/client/rails.rb:28:in load' 32: from /home/mvmarco/code/mvmarco/portfolio/bin/rails:9:in <top (required)>' 31: from /home/mvmarco/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:324:in require' 30: from /home/mvmarco/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:291:in load_dependency' 29: from /home/mvmarco/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/dependencies.rb:324:in block in require' 28: from /home/mvmarco/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in require' 27: from /home/mvmarco/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in require_with_bootsnap_lfi' 26: from /home/mvmarco/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in register' 25: from /home/mvmarco/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in block in require_with_bootsnap_lfi' 24: from /home/mvmarco/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in require' 23: from /home/mvmarco/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/railties-6.0.3.4/lib/rails/commands.rb:18:in ' 22: from /home/mvmarco/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/railties-6.0.3.4/lib/rails/command.rb:46:in invoke' 21: from /home/mvmarco/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/railties-6.0.3.4/lib/rails/command/base.rb:69:in perform' 20: from /home/mvmarco/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor.rb:392:in dispatch' 19: from /home/mvmarco/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/invocation.rb:127:in invoke_command' 18: from /home/mvmarco/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/command.rb:27:in run' 17: from /home/mvmarco/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/railties-6.0.3.4/lib/rails/commands/server/server_command.rb:138:in perform' 16: from /home/mvmarco/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/railties-6.0.3.4/lib/rails/commands/server/server_command.rb:138:in tap' 15: from /home/mvmarco/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/railties-6.0.3.4/lib/rails/commands/server/server_command.rb:147:in block in perform' 14: from /home/mvmarco/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/railties-6.0.3.4/lib/rails/commands/server/server_command.rb:39:in start' 13: from /home/mvmarco/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rack-2.2.3/lib/rack/server.rb:327:in start' 12: from /home/mvmarco/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/puma-4.3.6/lib/rack/handler/puma.rb:73:in run' 11: from /home/mvmarco/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/puma-4.3.6/lib/puma/launcher.rb:172:in run' 10: from /home/mvmarco/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/puma-4.3.6/lib/puma/single.rb:98:in run' 9: from /home/mvmarco/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/puma-4.3.6/lib/puma/runner.rb:161:in load_and_bind' 8: from /home/mvmarco/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/puma-4.3.6/lib/puma/binder.rb:90:in parse' 7: from /home/mvmarco/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/puma-4.3.6/lib/puma/binder.rb:90:in each' 6: from /home/mvmarco/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/puma-4.3.6/lib/puma/binder.rb:106:in block in parse' 5: from /home/mvmarco/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/puma-4.3.6/lib/puma/binder.rb:222:in add_tcp_listener' 4: from /home/mvmarco/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/puma-4.3.6/lib/puma/binder.rb:222:in each' 3: from /home/mvmarco/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/puma-4.3.6/lib/puma/binder.rb:223:in block in add_tcp_listener' 2: from /home/mvmarco/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/puma-4.3.6/lib/puma/binder.rb:229:in add_tcp_listener' 1: from /home/mvmarco/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/puma-4.3.6/lib/puma/binder.rb:229:in new' /home/mvmarco/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/puma-4.3.6/lib/puma/binder.rb:229:in `initialize': Address already in use - bind(2) for "127.0.0.1" port 3000 (Errno::EADDRINUSE)

I get the above error. I tried to do:

  1. lsof -wni tcp:3000 I GET: NO RESULTS
  2. ps aux | grep puma
    I GET: mvmarco 7805 0.0 0.0 6304 724 pts/0 S+ 20:52 0:00 grep --color puma
  3. kill -9 7805 I GET: kill: kill 7805 failed: no such process
  4. kill PID I GET: kill: illegal pid: PID
  5. sudo fuser -k -n tcp port I GET: Cannot resolve local port port: Servname not supported for ai_socktype

EVERYTHING WAS WORKING BEFORE I DID A SETUP FOR MY INTERNSHIP, THEY USE DOCKER. I AM WONDERING HOW TO LET IT WORK AGAIN

RubyOnRails : read parameter from the database once

How does this happen in RubyOnRails:
The parameter is stored in the database.
The program needs to read it from the database once upon user login and save them in a global variable.
While the user is working, he uses only this variable, and the program does not read parameter again from the DB, only the next time the user logs on to the system.
How it is implemented.

Devise: Log user out after the confirmation period ends

I have a setup for logging the user out of the application once the confirmation period ends. Also, I need the user to be only logged out at night at 2 AM.

For this, I overrode the following -

def confirmation_period_valid?
  confirmation_time = confirmation_sent_at.in_time_zone(time_zone).end_of_day + 2.hours
  unconfirmed_access_time = self.class.allow_unconfirmed_access_for.ago.in_time_zone(time_zone)
  confirmation_sent_at && confirmation_time >= unconfirmed_access_time
end

But when I check after the expiration period, I am still able to use the application. The user is not logged out.

Checking the rails console shows that the confirmation period is not valid for the user so that works.

jeudi 14 janvier 2021

Rack::OAuth2::Client::Error in rails 3 app after authenticating user

In my rails project, I am using the oauth2 gem for authentication. In the configuration, I have configured authentication, token, and user info URL correctly. When the user is login and redirected back to the callback URL I am getting the following error and I am not able to figure out what's wrong in the code.

Rack::OAuth2::Client::Error
Invalid authentication method for accessing this endpoint.

rack-oauth2 (1.0.8) lib/rack/oauth2/client.rb:119:in `handle_error_response'
rack-oauth2 (1.0.8) lib/rack/oauth2/client.rb:96:in `handle_response'
rack-oauth2 (1.0.8) lib/rack/oauth2/client.rb:70:in `access_token!'
omniauth-openid-connect (0.1.0) lib/omniauth/strategies/openid_connect.rb:83:in `access_token'
omniauth-openid-connect (0.1.0) lib/omniauth/strategies/openid_connect.rb:68:in `callback_phase'
omniauth (1.2.2) lib/omniauth/strategy.rb:227:in `callback_call'
omniauth (1.2.2) lib/omniauth/strategy.rb:184:in `call!'
omniauth (1.2.2) lib/omniauth/strategy.rb:164:in `call'
omniauth (1.2.2) lib/omniauth/builder.rb:59:in `call'
meta_request (0.2.1) lib/meta_request/middlewares/app_request_handler.rb:11:in `call'
rack-contrib (1.2.0) lib/rack/contrib/response_headers.rb:17:in `call'
meta_request (0.2.1) lib/meta_request/middlewares/headers.rb:16:in `call'
meta_request (0.2.1) lib/meta_request/middlewares/meta_request_handler.rb:13:in `call'
rack-openid (1.3.1) lib/rack/openid.rb:98:in `call'
actionpack (3.2.21) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.7) lib/rack/etag.rb:23:in `call'
rack (1.4.7) lib/rack/conditionalget.rb:25:in `call'
actionpack (3.2.21) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.2.21) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.21) lib/action_dispatch/middleware/flash.rb:242:in `call'
rack (1.4.7) lib/rack/session/abstract/id.rb:210:in `context'
rack (1.4.7) lib/rack/session/abstract/id.rb:205:in `call'
actionpack (3.2.21) lib/action_dispatch/middleware/cookies.rb:341:in `call'
activerecord (3.2.21) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.2.21) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
actionpack (3.2.21) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (3.2.21) lib/active_support/callbacks.rb:405:in `_run__2379598500685443395__call__5000626384124356__callbacks'
activesupport (3.2.21) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.21) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.21) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.21) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.21) lib/action_dispatch/middleware/reloader.rb:65:in `call'
actionpack (3.2.21) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
actionpack (3.2.21) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.21) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.21) lib/rails/rack/logger.rb:32:in `call_app'
railties (3.2.21) lib/rails/rack/logger.rb:16:in `block in call'
activesupport (3.2.21) lib/active_support/tagged_logging.rb:22:in `tagged'
railties (3.2.21) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.21) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.7) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.7) lib/rack/runtime.rb:17:in `call'
rack (1.4.7) lib/rack/lock.rb:15:in `call'
actionpack (3.2.21) lib/action_dispatch/middleware/static.rb:83:in `call'
rack-cors (0.4.0) lib/rack/cors.rb:80:in `call'
utf8-cleaner (0.2.3) lib/utf8-cleaner/middleware.rb:21:in `call'
railties (3.2.21) lib/rails/engine.rb:484:in `call'
railties (3.2.21) lib/rails/application.rb:231:in `call'
railties (3.2.21) lib/rails/railtie/configurable.rb:30:in `method_missing'
utf8-cleaner (0.2.3) lib/utf8-cleaner/middleware.rb:21:in `call'
passenger (4.0.29) lib/phusion_passenger/rack/thread_handler_extension.rb:77:in `process_request'
passenger (4.0.29) lib/phusion_passenger/request_handler/thread_handler.rb:140:in `accept_and_process_next_request'
passenger (4.0.29) lib/phusion_passenger/request_handler/thread_handler.rb:108:in `main_loop'
passenger (4.0.29) lib/phusion_passenger/request_handler.rb:441:in `block (3 levels) in start_threads'
Request
Parameters:

{"code"=>"ND_VQvqLqGVCPXBxxvYf6gP43kg",
 "iss"=>"https://dev-sso.sungardas.com/am/oauth2/realms/root/realms/SungardAS",
 "client_id"=>"viewpoint"}

lundi 11 janvier 2021

How to update related attributes while saving objects in Rails Active Record

My current logic is, taking two inputs from form where one is primary book and one is secondary book and save it to database with is_primary check being true for primary book and false for secondary. We can have multiple secondary books.

I have a table books: Table name: books

  • book_id
  • book_name

And I have another table authors: Table name: authors

  • author_id
  • author_name

And I have relation table as below: Table name: author_book

  • author_book_id
  • book_id
  • author_id
  • is_primary (Bool)

Code for form:

  <div class="elem-set">
    <div class="elem-label">
      <label>Author</label>
    </div>

    <%= f.select :associated_author,
    Author.sort_by_name.map{|t| ["#{t.id}: #{t.name}", t.name]},
    { include_blank: "No Author" },
    { class: 'chzn-select', multiple: false }
    %><br /><br />
  </div>


  <div class="elem-set">
    <div class="elem-label">
      <label>Primary Book</label>
    </div>

    <%= f.select :associated_primary_book,
    Book.sort_by_name.map{|n| ["#{n.book_name}: #{n.book_id}", n.book_name]},
    { include_blank: "No Book" },
    { class: 'chzn-select', multiple: false }
    %><br /><br />
  </div>


  <div class="elem-set">
    <div class="elem-label">
      <label>Secondary Book</label>
    </div>

    <%= f.select :associated_secondary_book,
    Book.sort_by_name.map{|n| ["#{n.book_name}: #{n.book_id}", n.book_name]},
    { include_blank: "No Book" },
    { class: 'chzn-select', multiple: true }
    %><br /><br />
  </div>

MODEL Book class:

class Book < ActiveRecord::Base
    has_many :author_book, dependent: :destroy
    has_many :authors, through: :author_book

    scope :sort_by_name, -> { select([:book_id, :book_name]).order('book_name ASC') }
end

Authors class:

class Author < ActiveRecord::Base
  has_many :author_book, dependent: :destroy
  has_many :books, through: :author_book
  def associated_primary_books=(fetched_books)
    self.books.clear
    if !fetched_books.empty?
        self.books << Book.find_by_name(fetched_books)
        #is_primary=> true
    end
  end


  def associated_secondary_books=(fetched_books)
    fetched_books = fetched_books.delete_if { |x| x.empty? }
    if !fetched_books.empty?
      fetched_books.each do |book|
        self.books << Book.find_by_name(book)
      end
    end
  end
  
end

AuthorBook class:

class AuthorBook < ActiveRecord::Base
  belongs_to :authors
  belongs_to :books
  
end

Controller Author controller

AuthorController < ApplicationController
  def create
    @Author = Author.new(params[:author])

    respond_to do |format|
      begin
        retries ||= 0
        if @author.save
          flash[:notice] = 'Author created.'
          Event.init(user: current_user.id, type: "Create Author", details: {
            :author => @author.id
          })
          format.html { redirect_to action: 'show',
                :id => @author.id
          }
        end
      rescue ActiveRecord::StatementInvalid => e
        flash[:error] = 'error'
        redirect_to action: 'new'
      end
    end
  end

ISSUE: What I want to achieve is whenever I save book object, I also somehow save the is_primary as true or false which is present in author_book table.

  1. When I try to add book to author, it gets saved successfully. But I am unable to update the is_primary attribute resulting in all books as secondary. I get undefined method error if I try to update the is_primary attribute. How do I access the is_primary attribute which is present in relation table and solve this cleanly?
  2. If I try to update the author_book table after adding Book, it returns empty array because everything is saved after Author is created.
  3. This is stub code with example I created and not the complete code.

We are using Rails 3.

vendredi 8 janvier 2021

You have to wait 2 minutes to post. Multiple validates

The User has to wait 10 minutes to post again IF he:

  • PREVIOUSLY posted less then 2 minutes ago or
  • PREVIOUSLY posted a short comment (less then 20 characters) or
  • PREVIOUSLY posted the same text or
  • PREVIOUSLY posted a link.

in my models/comment.rb I added this

  scope :time_interval, -> { where('created_at > ?', 2.minutes.ago) }
  validate :check_probably_spam!

  def check_probably_spam!
    errors.add(
      :base, :check_probably_spam
    ) if (user.comments.time_interval.any?) || (...) ||  (...) ||  (...)
  end

I was able to made only the first task. Any tips to complete it?

The hardest part is to know how to have the previous comment.

Please, help me

mercredi 6 janvier 2021

How to remove header of the table in rails?

https://i.stack.imgur.com/19Xjt.png

I created this table in rails and when I press the delete all button it deletes all of the items in the table. But it leaves the header of the table. How can I delete it together with other items when pressing the delete all button?

vendredi 1 janvier 2021

When I start Metasploit comes up an error, how do I fix this?

I tried to start metasploit but then came this:

msfconsole WARN: Unresolved or ambiguous specs during Gem::Specification.reset: reline (>= 0) Available/installed versions of this gem: - 0.1.5 - 0.1.3 WARN: Clearing out unresolved specs. Try 'gem cleanup ' Please report a bug if this causes problems. Traceback (most recent call last): 13: from /usr/bin/msfconsole:23:in <main>' 12: from /usr/share/metasploit-framework/lib/metasploit/framework/command/base.rb:81:in start'

11: from /usr/share/metasploit-framework/lib/metasploit/framework/command/base.rb:55:in `require_environment!'

10: from /usr/share/metasploit-framework/lib/metasploit/framework/command/base.rb:55:in `require'

9: from /usr/share/metasploit-framework/config/application.rb:10:in `<top (required)>'

8: from /usr/share/rubygems-integration/all/gems/bundler-2.1.4/lib/bundler.rb:174:in `require'

7: from /usr/share/rubygems-integration/all/gems/bundler-2.1.4/lib/bundler/runtime.rb:58:in `require'

6: from /usr/share/rubygems-integration/all/gems/bundler-2.1.4/lib/bundler/runtime.rb:58:in `each'

5: from /usr/share/rubygems-integration/all/gems/bundler-2.1.4/lib/bundler/runtime.rb:69:in `block in require'

4: from /usr/share/rubygems-integration/all/gems/bundler-2.1.4/lib/bundler/runtime.rb:69:in `each'

3: from /usr/share/rubygems-integration/all/gems/bundler-2.1.4/lib/bundler/runtime.rb:74:in `block (2 levels) in require'

2: from /usr/share/rubygems-integration/all/gems/bundler-2.1.4/lib/bundler/runtime.rb:74:in `require'

1: from /usr/share/metasploit-framework/vendor/bundle/ruby/2.7.0/gems/sqlite3-1.3.13/lib/sqlite3.rb:4:in `<top (required)>'

/usr/share/metasploit-framework/vendor/bundle/ruby/2.7.0/gems/sqlite3-1.3.13/lib/sqlite3.rb:4:in `require': cannot load such file -- sqlite3/2.7/sqlite3_native (LoadError)

14: from /usr/bin/msfconsole:23:in `'

13: from /usr/share/metasploit-framework/lib/metasploit/framework/command/base.rb:81:in `start'

12: from /usr/share/metasploit-framework/lib/metasploit/framework/command/base.rb:55:in `require_environment!'

11: from /usr/share/metasploit-framework/lib/metasploit/framework/command/base.rb:55:in `require'

10: from /usr/share/metasploit-framework/config/application.rb:10:in `<top (required)>'

9: from /usr/share/rubygems-integration/all/gems/bundler-2.1.4/lib/bundler.rb:174:in `require'

8: from /usr/share/rubygems-integration/all/gems/bundler-2.1.4/lib/bundler/runtime.rb:58:in `require'

7: from /usr/share/rubygems-integration/all/gems/bundler-2.1.4/lib/bundler/runtime.rb:58:in `each'

6: from /usr/share/rubygems-integration/all/gems/bundler-2.1.4/lib/bundler/runtime.rb:69:in `block in require'

5: from /usr/share/rubygems-integration/all/gems/bundler-2.1.4/lib/bundler/runtime.rb:69:in `each'

4: from /usr/share/rubygems-integration/all/gems/bundler-2.1.4/lib/bundler/runtime.rb:74:in `block (2 levels) in require'

3: from /usr/share/rubygems-integration/all/gems/bundler-2.1.4/lib/bundler/runtime.rb:74:in `require'

2: from /usr/share/metasploit-framework/vendor/bundle/ruby/2.7.0/gems/sqlite3-1.3.13/lib/sqlite3.rb:2:in `<top (required)>'

1: from /usr/share/metasploit-framework/vendor/bundle/ruby/2.7.0/gems/sqlite3-1.3.13/lib/sqlite3.rb:6:in `rescue in <top (required)>'

/usr/share/metasploit-framework/vendor/bundle/ruby/2.7.0/gems/sqlite3-1.3.13

/lib/sqlite3.rb:6:in `require': /usr/share/metasploit-framework/vendor/bundle/ruby/2.7.0

/gems/sqlite3-1.3.13/lib/sqlite3/sqlite3_native.so: undefined symbol: sqlite3_column_database_name - /usr/share/metasploit-framework/vendor/bundle/ruby/2.7.0/gems/sqlite3-1.3.13/lib/sqlite3/sqlite3_native.so (LoadError)

I do not know if the error is related to the fact that I installed something with sqlite3.

my Os:

lsb_release -a

No LSB modules are available.

Distributor ID: Parrot

Description: Parrot GNU/Linux 4.10

Release: 4.10

Codename: n/a

my gems:

gem list

*** LOCAL GEMS ***

actioncable (6.0.3.4)

actionmailbox (6.0.3.4)

actionmailer (6.0.3.4)

actionpack (6.0.3.4)

actiontext (6.0.3.4)

actionview (6.0.3.4)

activejob (6.0.3.4)

activemodel (6.0.3.4)

activerecord (6.0.3.4)

activestorage (6.0.3.4)

activesupport (6.0.3.4)

addressable (2.7.0)

ansi (1.5.0)

async (1.26.2)

async-dns (1.2.5)

async-http (0.52.5)

async-io (1.30.1)

async-pool (0.3.2)

atomic (1.1.16)

bcrypt_pbkdf (1.0.1)

benchmark (default: 0.1.0)

bigdecimal (default: 2.0.0)

bindex (0.5.0)

bootsnap (1.4.6)

buftok (0.2.0)

builder (3.2.4)

bundler (2.2.3, 2.1.4, 1.17.3)

byebug (11.1.3)

capybara (3.12.0)

celluloid (0.16.0)

celluloid-io (0.16.2)

cgi (default: 0.1.0)

childprocess (4.0.0)

cms_scanner (0.12.1)

coffee-rails (5.0.0)

coffee-script (2.4.1)

coffee-script-source (1.12.2)

colorize (0.8.1)

columnize (0.9.0)

concurrent-ruby (1.1.6)

concurrent-ruby-edge (0.6.0)

connection_pool (2.2.2)

console (1.8.2)

crass (1.0.2)

csv (default: 3.1.2)

daemons (1.1.9)

date (default: 3.0.0)

dbm (default: 1.1.0)

delegate (default: 0.1.0)

did_you_mean (default: 1.4.0)

domain_name (0.5.20160216)

ed25519 (1.2.4)

em-websocket (0.5.1)

equalizer (0.0.11)

erubi (1.10.0, 1.9.0)

erubis (2.7.0)

espeak-ruby (1.0.4)

etc (default: 1.1.0)

ethon (0.9.0)

eventmachine (1.3.0.dev.1)

evil-winrm (2.3)

excon (0.72.0)

execjs (2.7.0)

fcntl (default: 1.0.0)

ffi (1.12.2)

ffi-compiler (1.0.1)

fiddle (default: 1.0.0)

fileutils (default: 1.4.1)

fog-core (2.1.0)

fog-json (1.2.0)

fog-libvirt (0.6.0)

fog-xml (0.1.1)

formatador (0.2.5)

forwardable (default: 1.3.1)

gdbm (default: 2.1.0)

get_process_mem (0.2.5)

getoptlong (default: 0.1.0)

globalid (0.3.6)

gssapi (1.3.1)

gyoku (1.3.1)

hashie (3.5.5)

hashie-forbidden_attributes (0.1.1)

hike (1.2.1)

hitimes (1.2.1)

http (4.4.1)

http-cookie (1.0.3)

http-form_data (2.2.0)

http-parser (1.2.1)

http_parser.rb (0.6.0)

httpclient (2.8.3)

i18n (1.8.5)

io-console (default: 0.5.6)

ipaddr (default: 1.2.2)

ipaddress (0.8.3)

irb (default: 1.2.6)

jbuilder (2.10.0)

json (default: 2.3.0)

listen (3.2.1)

little-plugger (1.1.4)

log4r (1.1.10)

logger (default: 1.4.2)

logging (2.3.0)

loofah (2.7.0)

mail (2.7.1)

marcel (0.3.2)

matrix (default: 0.2.0)

maxmind-db (1.0.0)

memoizable (0.4.2)

method_source (1.0.0)

mime (0.4.4)

mime-types (3.3.1)

mime-types-data (3.2015.1120)

mimemagic (0.3.5)

mini_exiftool (2.9.0)

mini_mime (1.0.2)

minitest (5.14.0, 5.13.0)

mojo_magick (0.5.6)

molinillo (0.6.4)

msfrpc-client (1.1.2)

msgpack (1.1.0)

multi_json (1.14.1)

multipart-post (2.0.0)

mustermann (1.1.1)

mutex_m (default: 0.1.0)

naught (1.1.0)

net-http-digest_auth (1.4)

net-http-persistent (3.1.0)

net-pop (default: 0.1.0)

net-scp (3.0.0)

net-sftp (2.1.2)

net-smtp (default: 0.1.0)

net-ssh (6.1.0)

net-telnet (0.1.1)

netrc (0.11.0)

nio4r (2.3.1)

nokogiri (1.10.9)

nori (2.6.0)

observer (default: 0.1.0)

oj (3.10.13)

open3 (default: 0.1.0)

openssl (default: 2.1.2)

opt_parse_validator (1.9.2)

ostruct (default: 0.2.0)

otr-activerecord (1.4.1)

parseconfig (1.0.8)

pkg-config (1.4.4)

power_assert (1.1.7)

prime (default: 0.1.1)

protocol-hpack (1.4.2)

protocol-http (0.20.0)

protocol-http1 (0.13.1)

protocol-http2 (0.14.0)

pstore (default: 0.1.0)

psych (default: 3.1.0)

public_suffix (4.0.3)

puma (4.3.6)

qr4r (0.4.1)

racc (default: 1.4.16)

rack (2.1.1)

rack-protection (2.0.8.1)

rack-proxy (0.6.1)

rack-test (0.7.0)

rails (6.0.3.4)

rails-deprecated_sanitizer (1.0.3)

rails-dom-testing (2.0.3)

rails-html-sanitizer (1.3.0)

railties (6.0.3.4)

rake (13.0.1)

rb-inotify (0.9.10)

rchardet (1.8.0)

rdoc (default: 6.2.1)

readline (default: 0.0.2)

readline-ext (default: 0.1.0)

regexp_parser (1.7.1)

reline (0.2.0, default: 0.1.5)

rest-client (2.0.2)

rexml (default: 3.2.3)

rqrcode_core (0.1.2)

rss (default: 0.2.8)

ruby (0.1.0)

ruby-libvirt (0.7.1)

ruby-progressbar (1.10.1)

ruby2_keywords (0.0.2)

rubydns (1.0.3)

rubyntlm (0.6.2)

rubyzip (2.0.0)

rushover (0.3.0)

sass (3.7.4)

sass-rails (6.0.0)

sassc (2.2.1)

sassc-rails (2.1.2)

sdbm (default: 1.0.0)

selenium-webdriver (3.142.7)

simple_oauth (0.3.1)

sinatra (2.0.8.1)

singleton (default: 0.1.0)

slack-notifier (1.5.1)

snmp (1.3.1)

spider (0.42)

spring (2.1.0)

spring-watcher-listen (2.0.1)

sprockets (3.7.2)

sprockets-rails (3.2.1)

stringio (default: 0.1.0)

strscan (default: 1.0.3)

sync (0.5.0)

term-ansicolor (1.3.0)

test-unit (3.3.5)

thin (1.7.2)

thor (0.20.3)

thread_safe (0.3.6)

tilt (2.0.10)

timeout (default: 0.1.0)

timers (4.1.1)

tins (1.1.0)

tracer (default: 0.1.0)

turbolinks (5.1.1)

turbolinks-source (5.1.0)

twitter (7.0.0)

typhoeus (1.4.0)

tzinfo (1.2.7, 1.2.6)

uglifier (2.7.2)

unf (0.1.4)

unf_ext (0.0.7.6)

uri (default: 0.10.0)

vagrant (2.2.9)

vagrant-libvirt (0.3.0)

vagrant_cloud (2.0.3)

web-console (4.0.1)

webpacker (4.2.2) webrick (default: 1.6.0)

websocket-driver (0.6.3)

websocket-extensions (0.1.5)

winrm (2.3.5)

winrm-fs (1.3.5)

wpscan (3.8.10)

xmlrpc (0.3.0)

xpath (3.2.0)

yajl-ruby (1.4.1)

yaml (default: 0.1.0)

zeitwerk (2.4.2, 2.3.0)

zlib (default: 1.1.0)

reline gem:

gem list reline

*** LOCAL GEMS ***

reline (0.2.0, default: 0.1.5)

i tried also: gem cleanup reline

gem install reline

reinstalling metasploit

search in the web and try the commands that I though that they resolve my problem.

I want that metasploit works and pls be not toxic I am a noob in metasploit