in views file. <%= render ''row'', :object => @row_1 %> _row_html.erb <% row.each do |i| %> <%- if i.nil? -%> <%= render ''users/signup'' %> <%- elsif i.respond_to?(''category_id'') -%> <%# render partial_for_post(i.category_id), :object => i %> <%= i.module %> <%- end -%> <% end %> if I write i.class it returns Post, so I thought module will be a method in post_controller.rb. But it''s not, can any one tell me, what is it, and where can I get codes written for i.module. Thanks -- Posted via http://www.ruby-forum.com/. -- 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.
Am 13.09.2010 um 14:58 schrieb Awijeet Mr.:> if I write i.class it returns Post, so I thought module will be a > method in post_controller.rb. But it''s notIf i is of the type Post, i.module will call the method module from the Post object in app/models/post.rb, not from a PostsController object as you seem to think it will. Felix -- 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.
Post (singular with capital) is the model On Mon, Sep 13, 2010 at 9:02 AM, Felix Schäfer <schaefer-SjIeUF6ADzXby3iVrkZq2A@public.gmane.org>wrote:> > Am 13.09.2010 um 14:58 schrieb Awijeet Mr.: > > > if I write i.class it returns Post, so I thought module will be a > > method in post_controller.rb. But it''s not > > If i is of the type Post, i.module will call the method module from the > Post object in app/models/post.rb, not from a PostsController object as you > seem to think it will. > > Felix > > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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.
Felix Schäfer wrote:> Am 13.09.2010 um 14:58 schrieb Awijeet Mr.: > >> if I write i.class it returns Post, so I thought module will be a >> method in post_controller.rb. But it''s not > > If i is of the type Post, i.module will call the method module from the > Post object in app/models/post.rb, not from a PostsController object as > you seem to think it will. > > FelixI have checked the code in app/models/post.rb there are no module method, but at lot of space self.module function has been called, and a defined method is def set_module -- Posted via http://www.ruby-forum.com/. -- 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.
radhames brito wrote:> Post (singular with capital) is the modelthat''s true, but here instead of Post.module, i.module is called. and to know it''s class when i put i.class it said Post, and in app/models/post.rb no module function is there.. :( -- Posted via http://www.ruby-forum.com/. -- 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.
Post. module is not the same as i.module, i is an instance of the Post class that means you can do Post.name == i.class.name and returns true. acording to ruby docs this is what a module is "A Module <http://ruby-doc.org/core/classes/Module.html> is a collection of methods and constants <http://ruby-doc.org/core/classes/Module.html#M001656>. The methods in a module may be instance methods or module methods. Instance methods appear as methods in a class when the module is included<http://ruby-doc.org/core/classes/Module.html#M001660>, module methods do not. Conversely, module methods may be called without creating an encapsulating object, while instance methods may not. (See Module#module_function<http://ruby-doc.org/core/classes/Module.html#M001642>) " so what do you spect the module method to return from i.module? -- 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.