Can you show me the tipical project structure of rails app?

I am a newer of ruby language and rails framework, and I am not sure the
project structure. The core problems are where I should place the global
configuration items and my own components.

For instance, I want to define a admin account and use it in several
controllers like “my_conf.admin”.

Another instance, I define a class UserToken, which is a tool to handle
encrypted tokens. Through many surveys, I build a subdirectory named
utils
below app/controllers directory and in application.rb I wrote some code:

config.autoload_paths += %w!app/controllers/labs app/models/labs!

Now I can seperate class UserToken from the regular controllers and it
is
also loaded when need, so I have not to add some code such as
“require(‘utils/user_token.rb’)”.

And also, I want to extend the capability of mongoid with following
code:
initializers/mongoid.rb

module Mongoid
module Document
def serializable_hash(options={})
attrs = super(options)
attrs.delete(’_id’)
attrs[‘id’] = self.persisted? ? self._id : nil
includes = options[:include]
includes = [includes] if not includes.is_a? Array
includes.each { |include|
attrs.delete “#{include}_id”
}
attrs
end
end
end

Now I have placed it in directory “config/inititializers” because only
by
that way can server load it when app startup. Is it a proper way?

Those are my focusing points and there may be some other problems I have
not met yet. Could you give me some directions, please?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs