SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Guru Skyblaze's Avatar
    Join Date
    Jul 2005
    Location
    Italy
    Posts
    734
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Invoking methods....

    When you write rails code and for example in instance methods of our controller class we call rail's built in methods (like for example redirect_to etc.), on which object are we calling them? On the same instanced object right? That is the actual controller class instance is it? In essence we call for example one action/method of our controller class on the same instance of this class (actually rails do class instantiations and methods/actions invocations for us) plus others methods in concatenation that reside inside that particular action/method right?

  2. #2
    SitePoint Guru silver trophy Luke Redpath's Avatar
    Join Date
    Mar 2003
    Location
    London
    Posts
    794
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When you do this:

    Code:
    class MyController < ApplicationController
      def my_action
        redirect_to :action => 'foo'
      end
    end
    You are calling redirect_to which is an instance method of MyController, which is inherited from ApplicationController, which is inherited from ActionController::Base (which is the framework class that defines redirect_to).

    Rails handles the invocation of controller instances transparently.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •