On Thu, 2005-10-27 at 01:53 -0400, Neeraj Kumar wrote:> I though the best way to learn is to go through the existing code and
> decided to look under the hood of typo. Here are the questions that
> popped up in my mind.
>
> 1) admin/base_controller.rb
>
> .....
> cattr_accessor :look_for_migrations
> ....
>
> I looked at both ruby and rails api and couldn''t find anything
about
> "cattr_accessor".
>
activesupport/lib/active_support/class_attribute_accessors.rb
You can find it here:
http://rubyurl.com/bet
and
http://rubyurl.com/WnR
> 2)
>
http://typo.leetsoft.com/trac/file/trunk/app/controllers/admin/content_controller.rb
>
> In the method ''new''
>
> ....
> @article.allow_comments ||= config[:default_allow_comments]
> ....
>
> what is config? And how was it populated
Looks like here:
> class ApplicationController < ActionController::Base
> include LoginSystem
> model :user
>
> before_filter :reload_settings
> ...
>
> def reload_settings
> config.reload
> end
In app/models/configuration.rb, you''ll find:
> class Configuration < ConfigManager
> setting :blog_name, :string, ''My Shiny Weblog!''
> setting :blog_subtitle, :string, ''''
> setting :default_allow_pings, :bool, false
> setting :default_allow_comments, :bool, true
> setting :sp_global, :bool, false
> setting :sp_article_auto_close, :int, 0
> setting :sp_url_limit, :int, 0
> setting :text_filter, :string, ''''
> setting :comment_text_filter, :string, ''''
> setting :limit_article_display, :int, 10
> setting :limit_rss_display, :int, 10
> setting :geourl_location, :string, ''''
> setting :link_to_author, :bool, false
> setting :theme, :string, ''azure''
> end
>
> def config
> $config ||= Configuration.new
> end
Hope that helps!
Robby
--
/******************************************************
* Robby Russell, Owner.Developer.Geek
* PLANET ARGON, Open Source Solutions & Web Hosting
* Portland, Oregon | p: 503.351.4730 | f: 815.642.4068
* www.planetargon.com | www.robbyonrails.com
* Programming Rails | www.programmingrails.com
*******************************************************/