It's my first RoR application.
I want to use this class (app/models/from_db/users/user_base.rb)
module FromDb::Users class UserBase include ActiveModel::Serializers::JSON attr_accessor :Login, :Email end end In this controller (app/controllers/my_controller.rb)
class MyController < ApplicationController require "from_db/users/user_base" def default user = UserBase.new user.Login = "Marcin" user.Email = "[email protected]" end end user = UserBase.new throw this error:
uninitialized constant MyController::UserBase
When I put FromDb::Users::UserBase.new everything works fine but I thought that 'require' is like 'using' in C# or 'import' in java. I don't want to have to put this namespace all time before class from other dir. What I am doing wrong?
My second question. Is any way to write require "FromDb/Users/UserBase" instand of require "from_db/users/user_base" ? Now when I put first version (FromDb/Users/UserBase) it throw that error:
cannot load such file -- FromDb/Users/UserBase
I use ruby 2.1.5 and Rails 4.2.1