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?

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/3ef23458-5dc9-4d19-997b-6e85bb7c0c43%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to