I just started learning Rails and Ruby. The Ruby on Rails Guide at http://guides.rubyonrails.org/getting_started.html says that Rails consists of many different "components". Some of these components, such as ActiveRecord and ActionController, I've encountered in my Rails apps (in models and controllers, respectively).
The relevant syntax ("class Model < ActiveRecord::Base" and "class ApplicationController < ActionController::Base") make it look like these components are Ruby modules, but if they are modules in which files are they located? And how can we reference them without first using the Ruby method "require"?
UPDATE: So I found all of the built-in modules and classes. On my server, the path for the Base class of the ActiveRecord module (for example) is:
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.9/lib/active_record
But I still don't know why we can refer to these modules and classes in our models and controllers without first using Ruby's require method.
Rails components are modules which are included by default in application.rb
with require rails/all
:
validates :name, presence: true
) [].blank?
) If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With