Manuca
2009-Dec-17 02:06 UTC
Understanding where certain ''inherited'' methods come from in ActionController::Base
Hi I just started getting my hands on Rails, I''ve been reading a good book on the subject but now I want to continue by myself and with the help of the rails api documentation but I find it quite difficult to follow (copared with the Java generated docs for example). One thing that I still can''t get to understand is how methods like ''layout'' become available on my controllers to mention one example I supposed that the method was defined inside ActionController::Base but reading the docs I see there is no such thing defined there. Can you please clarify on this issue, I believe it may be something related to the Ruby that I still don''t know about. Thanks in advance. M. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Leonardo Mateo
2009-Dec-17 12:31 UTC
Re: Understanding where certain ''inherited'' methods come from in ActionController::Base
On Wed, Dec 16, 2009 at 11:06 PM, Manuca <manuca-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi I just started getting my hands on Rails, I''ve been reading a good > book on the subject but now I want to continue by myself and with the > help of the rails api documentation but I find it quite difficult to > follow (copared with the Java generated docs for example). > > One thing that I still can''t get to understand is how methods like > ''layout'' become available on my controllers to mention one example I > supposed that the method was defined inside ActionController::Base but > reading the docs I see there is no such thing defined there. > > Can you please clarify on this issue, I believe it may be something > related to the Ruby that I still don''t know about.Try apidock.com. http://apidock.com/rails/ActionController Hope it helps. -- Leonardo Mateo. There''s no place like ~ -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Manuca
2009-Dec-17 19:59 UTC
Re: Understanding where certain ''inherited'' methods come from in ActionController::Base
On Dec 17, 9:31 am, Leonardo Mateo <leonardoma...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Try apidock.com. > http://apidock.com/rails/ActionController > Hope it helps. >Ok thanks for the info, those docs seem more friendly, anyway, I still don''t understand where those methods (for ex. layout) get inherited or injected don''t know how that magic happens they aren''t mentioned even in apidock.com. Thanks m. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hassan Schroeder
2009-Dec-17 20:13 UTC
Re: Re: Understanding where certain ''inherited'' methods come from in ActionController::Base
On Thu, Dec 17, 2009 at 11:59 AM, Manuca <manuca-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Ok thanks for the info, those docs seem more friendly, anyway, I still > don''t understand where those methods (for ex. layout) get inherited or > injected don''t know how that magic happenswhen in doubt, cd to one of your projects and e.g. find vendor/rails -type f -exec grep -H ''def layout'' {} \; You''ll see exactly how the magic happens :-) (and in this case, also lots o'' comments). HTH, -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org twitter: @hassan -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Manuca
2009-Dec-17 20:48 UTC
Re: Understanding where certain ''inherited'' methods come from in ActionController::Base
On Dec 17, 5:13 pm, Hassan Schroeder <hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> when in doubt, cd to one of your projects and e.g. > find vendor/rails -type f -exec grep -H ''def layout'' {} \;Thanks again for the feedback, yep I already did a recursive grep inside my gems dirs and found those definitions I guess there i''ll find the real info, anyway what I find confusing is that in the docs those automatic inclusions are not mentioned, maybe those are obvious or implicit and they can be derived from the module name I really don''t know because Im also new to the Ruby language. Is it possible that because both ActionController::Base and ActionController::Layout::ClassMethods share th ''ActionController'' module they are inside the same namespace and all public methods of Layout are available to Base? Can I conclude that this is the case with all clases inside ActionController? Please excuse my enormouse ignorance on the subject Thanks for you patience! m. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Yehuda Katz
2009-Dec-17 21:21 UTC
Re: Understanding where certain ''inherited'' methods come from in ActionController::Base
It might be easier to understand what''s going on in Rails master. Take a look at http://github.com/rails/rails/blob/master/actionpack/lib/action_controller/base.rb#L5-37. As you can see, the Base class is including a series of modules. In Ruby, modules are like dynamic superclasses; including one adds the module to the superclass chain. For instance, observe that ActionController::Base includes ActionController::UrlFor. You can follow that module to http://github.com/rails/rails/blob/master/actionpack/lib/action_controller/metal/url_for.rb, which has the much-used url_for method (http://github.com/rails/rails/ blob/master/actionpack/lib/action_controller/metal/url_for.rb#L28-39). Hope this helps. -- Yehuda On Dec 17, 12:48 pm, Manuca <man...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Dec 17, 5:13 pm, Hassan Schroeder <hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > when in doubt, cd to one of your projects and e.g. > > find vendor/rails -type f -exec grep -H ''def layout'' {} \; > > Thanks again for the feedback, yep I already did a recursive grep > inside my gems dirs and found those definitions I guess there i''ll > find the real info, anyway what I find confusing is that in the docs > those automatic inclusions are not mentioned, maybe those are obvious > or implicit and they can be derived from the module name I really > don''t know because Im also new to the Ruby language. > > Is it possible that because both ActionController::Base and > ActionController::Layout::ClassMethods share th ''ActionController'' > module they are inside the same namespace and all public methods of > Layout are available to Base? Can I conclude that this is the case > with all clases inside ActionController? > > Please excuse my enormouse ignorance on the subject > Thanks for you patience! > m.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Manuca
2009-Dec-19 02:52 UTC
Re: Understanding where certain ''inherited'' methods come from in ActionController::Base
On Dec 17, 6:21 pm, Yehuda Katz <wyc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hope this helps.Thanks Yehuda that was of help. m. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.