i have created a gem locally by the name of "usersearch". Inside the lib folder, I have a "User" folder and a class named "User". I call the gem in to a ruby program and I want to create an object of "User" type. But the User class exists inside gem. How do i call it?
When you load/require a file, it is always loaded in the main namespace regardless of where you load/require. If you defined User
in a gem properly, and have required that gem, you should be able to refer to it by just writing User
unless you have defined it in some namespace such as Foo::User
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.