Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 194

Show
Ignore:
Timestamp:
12/16/04 17:45:37 (4 years ago)
Author:
david
Message:

Updated documentation

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/lib/action_controller/base.rb

    r142 r194  
    5959  # 
    6060  #   def hello_ip 
    61   #     location = @request.env["REMOTE_ADDRESS"] 
     61  #     location = @request.env["REMOTE_IP"] 
    6262  #     render_text "Hello stranger from #{location}" 
    6363  #   end 
  • trunk/actionpack/lib/action_controller/cookies.rb

    r117 r194  
    1111  #   cookies["user_name"] # => "david" 
    1212  #   cookies.size         # => 2 
     13  #  
     14  # Example for deleting: 
     15  # 
     16  #   cookies.delete "user_name" 
    1317  # 
    1418  # All the option symbols for setting cookies are: 
    1519  # 
    16   # value:: the cookie's value or list of values (as an array). 
    17   # path:: the path for which this cookie applies.  Defaults to the root of the application. 
    18   # domain:: the domain for which this cookie applies. 
    19   # expires:: the time at which this cookie expires, as a +Time+ object. 
    20   # secure:: whether this cookie is a secure cookie or not (default to false). 
    21   #          Secure cookies are only transmitted to HTTPS servers. 
     20  # * <tt>value</tt> - the cookie's value or list of values (as an array). 
     21  # * <tt>path</tt> - the path for which this cookie applies.  Defaults to the root of the application. 
     22  # * <tt>domain</tt> - the domain for which this cookie applies. 
     23  # * <tt>expires</tt> - the time at which this cookie expires, as a +Time+ object. 
     24  # * <tt>secure</tt> - whether this cookie is a secure cookie or not (default to false). 
     25  #   Secure cookies are only transmitted to HTTPS servers. 
    2226  module Cookies 
    2327    # Returns the cookie container, which operates as described above. 
  • trunk/actionpack/lib/action_controller/dependencies.rb

    r175 r194  
    2121    end 
    2222 
     23    # Dependencies control what classes are needed for the controller to run its course. This is an alternative to doing explicit 
     24    # +require+ statements that bring a number of benefits. It's more succinct, communicates what type of dependency we're talking about, 
     25    # can trigger special behavior (as in the case of +observer+), and enables Rails to be clever about reloading in cached environments 
     26    # like FCGI. Example: 
     27    # 
     28    #   class ApplicationController < ActionController::Base 
     29    #     model    :account, :company, :person, :project, :category 
     30    #     helper   :access_control 
     31    #     service  :notifications, :billings 
     32    #     observer :project_change_observer 
     33    #   end 
     34    # 
     35    # Please note that a controller like ApplicationController will automatically attempt to require_dependency on a model of its name and a helper 
     36    # of its name. If nothing is found, no error is raised. This is especially useful for concrete controllers like PostController: 
     37    # 
     38    #   class PostController < ApplicationController 
     39    #     # model  :post (already required) 
     40    #     # helper :post (already required) 
     41    #   end 
    2342    module ClassMethods 
    2443      # Loads the <tt>file_name</tt> if reload_dependencies is true or requires if it's false. 
     
    2746      end 
    2847       
     48      # Specifies a variable number of models that this controller depends on. Models are normally Active Record classes or a similar 
     49      # backend for modelling entity classes. 
    2950      def model(*models) 
    3051        require_dependencies(:model, models) 
     
    3253      end 
    3354 
     55      # Specifies a variable number of services that this controller depends on. Services are normally singletons or factories, like 
     56      # Action Mailer service or a Payment Gateway service. 
    3457      def service(*services) 
    3558        require_dependencies(:service, services) 
     
    3760      end 
    3861       
     62      # Specifies a variable number of observers that are to govern when this controller is handling actions. The observers will 
     63      # automatically have .instance called on them to make them active on assignment. 
    3964      def observer(*observers) 
    4065        require_dependencies(:observer, observers) 
     
    4368      end 
    4469 
    45       def dependencies_on(layer) # :nodoc: 
     70      # Returns an array of symbols that specify the dependencies on a given layer. For the example at the top, calling 
     71      # <tt>ApplicationController.dependencies_on(:model)</tt> would return <tt>[:account, :company, :person, :project, :category]</tt> 
     72      def dependencies_on(layer) 
    4673        read_inheritable_attribute("#{layer}_dependencies") 
    4774      end 
    4875     
    49       def depend_on(layer, dependencies) 
     76      def depend_on(layer, dependencies) #:nodoc: 
    5077        write_inheritable_array("#{layer}_dependencies", dependencies) 
    5178      end 
  • trunk/actionpack/lib/action_controller/helpers.rb

    r32 r194  
    3232      # See ActionView::Helpers (link:classes/ActionView/Helpers.html) for more about making your own helper modules  
    3333      # available to the templates. 
    34       def add_template_helper(helper_module) 
     34      def add_template_helper(helper_module) #:nodoc: 
    3535        template_class.class_eval "include #{helper_module}" 
    3636      end 
  • trunk/actionpack/lib/action_controller/rescue.rb

    r103 r194  
    1616    end 
    1717 
    18     module ClassMethods 
     18    module ClassMethods #:nodoc: 
    1919      def process_with_exception(request, response, exception) 
    2020        new.process(request, response, :rescue_action, exception) 
  • trunk/actionpack/lib/action_controller/test_process.rb

    r80 r194  
    188188end 
    189189 
    190 class Test::Unit::TestCase #:nodoc: 
    191   private   
    192     # execute the request and set/volley the response 
    193     def process(action, parameters = nil, session = nil) 
    194       @request.env['REQUEST_METHOD'] ||= "GET" 
    195       @request.action = action.to_s 
    196       @request.parameters.update(parameters) unless parameters.nil? 
    197       @request.session = ActionController::TestSession.new(session) unless session.nil? 
    198       @controller.process(@request, @response) 
    199     end 
    200      
    201     # execute the request simulating a specific http method and set/volley the response 
    202     %w( get post put delete head ).each do |method| 
    203       class_eval <<-EOV 
    204         def #{method}(action, parameters = nil, session = nil) 
    205           @request.env['REQUEST_METHOD'] = "#{method.upcase}" 
    206           process(action, parameters, session) 
     190module Test 
     191  module Unit 
     192    class TestCase #:nodoc: 
     193      private   
     194        # execute the request and set/volley the response 
     195        def process(action, parameters = nil, session = nil) 
     196          @request.env['REQUEST_METHOD'] ||= "GET" 
     197          @request.action = action.to_s 
     198          @request.parameters.update(parameters) unless parameters.nil? 
     199          @request.session = ActionController::TestSession.new(session) unless session.nil? 
     200          @controller.process(@request, @response) 
    207201        end 
    208       EOV 
    209     end 
    210  
     202     
     203        # execute the request simulating a specific http method and set/volley the response 
     204        %w( get post put delete head ).each do |method| 
     205          class_eval <<-EOV 
     206            def #{method}(action, parameters = nil, session = nil) 
     207              @request.env['REQUEST_METHOD'] = "#{method.upcase}" 
     208              process(action, parameters, session) 
     209            end 
     210          EOV 
     211        end 
     212    end 
     213  end 
    211214end 
  • trunk/actionpack/lib/action_view.rb

    r4 r194  
    2929  $:.unshift(File.dirname(__FILE__) + "/action_view/vendor") 
    3030  require 'action_view/vendor/builder' 
    31 ensure 
    32   # Temporary patch until it's in Builder 1.2.2 
    33   class BlankSlate 
    34     class << self 
    35       def hide(name) 
    36         undef_method name if instance_methods.include?(name) and name !~ /^(__|instance_eval)/ 
    37       end 
    38     end 
    39   end 
    4031end 
    4132 
  • trunk/actionpack/lib/action_view/base.rb

    r121 r194  
    142142    end 
    143143 
    144     def self.controller_delegate(*methods) 
     144    def self.controller_delegate(*methods)#:nodoc: 
    145145      methods.flatten.each do |method| 
    146146        class_eval <<-end_eval 
  • trunk/actionpack/lib/action_view/helpers/active_record_helper.rb

    r123 r194  
    8484      # of <tt>object_name</tt>. This div can be tailored by the following options: 
    8585      # 
    86       # ::header_tag: Used for the header of the error div (default: h2) 
    87       # ::id: The id of the error div (default: errorExplanation) 
    88       # ::class: The class of the error div (default: errorExplanation) 
     86      # * <tt>header_tag</tt> - Used for the header of the error div (default: h2) 
     87      # * <tt>id</tt> - The id of the error div (default: errorExplanation) 
     88      # * <tt>class</tt> - The class of the error div (default: errorExplanation) 
    8989      def error_messages_for(object_name, options={}) 
    9090        object = instance_eval "@#{object_name}" 
  • trunk/actionpack/lib/action_view/helpers/form_helper.rb

    r151 r194  
    9292      # Example (call, result). Imagine that @post.validated? returns 1: 
    9393      #   check_box("post", "validated") 
    94       #     <input type="checkbox" id="post_validate" name="post[validated] value="1" checked="checked" /><input name="post[validated]" type="hidden" value="0" /> 
     94      #     <input type="checkbox" id="post_validate" name="post[validated] value="1" checked="checked" /> 
     95      #     <input name="post[validated]" type="hidden" value="0" /> 
    9596      # 
    9697      # Example (call, result). Imagine that @puppy.gooddog returns no: 
    9798      #   check_box("puppy", "gooddog", {}, "yes", "no") 
    98       #     <input type="checkbox" id="puppy_gooddog" name="puppy[gooddog] value="yes" /><input name="puppy[gooddog]" type="hidden" value="no" /> 
     99      #     <input type="checkbox" id="puppy_gooddog" name="puppy[gooddog] value="yes" /> 
     100      #     <input name="puppy[gooddog]" type="hidden" value="no" /> 
    99101      def check_box(object, method, options = {}, checked_value = "1", unchecked_value = "0") 
    100102        InstanceTag.new(object, method, self).to_check_box_tag(options, checked_value, unchecked_value) 
  • trunk/actionpack/lib/action_view/helpers/tag_helper.rb

    r114 r194  
    88 
    99      # Examples:  
    10       # * tag("br") => <br /
    11       # * tag("input", { "type" => "text"}) => <input type="text" /
     10      # * <tt>tag("br") => <br /></tt
     11      # * <tt>tag("input", { "type" => "text"}) => <input type="text" /></tt
    1212      def tag(name, options = {}, open = false) 
    1313        "<#{name}#{tag_options(options)}" + (open ? ">" : " />") 
     
    1515       
    1616      # Examples:  
    17       # * content_tag("p", "Hello world!") => <p>Hello world!</p
    18       # * content_tag("div", content_tag("p", "Hello world!"), "class" => "strong") =>  
    19       #   <div class="strong"><p>Hello world!</p></div
     17      # * <tt>content_tag("p", "Hello world!") => <p>Hello world!</p></tt
     18      # * <tt>content_tag("div", content_tag("p", "Hello world!"), "class" => "strong") => </tt> 
     19      #   <tt><div class="strong"><p>Hello world!</p></div></tt
    2020      def content_tag(name, content, options = {}) 
    2121        "<#{name}#{tag_options(options)}>#{content}</#{name}>" 
  • trunk/actionpack/lib/action_view/helpers/url_helper.rb

    r106 r194  
    3131      # letting the following special values enter the options on the image and the rest goes to the ahref: 
    3232      # 
    33       # ::alt: If no alt text is given, the file name part of the +src+ is used (capitalized and without the extension) 
    34       # ::size: Supplied as "XxY", so "30x45" becomes width="30" and height="45" 
    35       # ::border: Is set to 0 by default 
    36       # ::align: Sets the alignment, no special features 
     33      # * <tt>alt</tt> - If no alt text is given, the file name part of the +src+ is used (capitalized and without the extension) 
     34      # * <tt>size</tt> - Supplied as "XxY", so "30x45" becomes width="30" and height="45" 
     35      # * <tt>border</tt> - Is set to 0 by default 
     36      # * <tt>align</tt> - Sets the alignment, no special features 
    3737      # 
    3838      # The +src+ can be supplied as a...