Home>

I am a beginner in programming.
Currently, I am learning along with the Ruby on Rails 5 Quick Learning Practice Guide that can be used on site.
Create p14 User class and save it in the count directory.
In order to use the User class, an error appears in the part that starts irb and loads user.rb using require.
user.rb is stored in /home/kei displayed as pwd in ubuntu.
I would appreciate it if you could tell me how to solve it.

[email protected]:~$irb
irb(main):001:0>require'./user.rb'
Traceback (most recent call last):
        4: from /home/kei/.rbenv/versions/2.5.8/bin/irb:11:in `<main>'
        3: from (irb):1
        2: from /home/kei/.rbenv/versions/2.5.8/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:92:in `require'
        1: from /home/kei/.rbenv/versions/2.5.8/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:92:in `require'
LoadError (cannot load such file-./user.rb)
irb(main):002:0>
Applicable source code
class User
end
What I tried

・Execute with require_relative

irb(main):002:0>require_relative'./user.rb'
Traceback (most recent call last):
3: from /home/kei/.rbenv/versions/2.5.8/bin/irb:11:in

' 2: from (irb):2 1: from (irb):2:inrequire_relative'
LoadError (cannot load such file --/home/kei/user.rb)

Supplementary information (FW/tool ​​version, etc.)

ruby 2.5.8
Ubuntu 20.04

  • Answer # 1

    ---------- 1 kei kei 15 Jul 28 11:15 user.rb
    So no one has access.
    chmod 766 user.rb
    please