View and Controllers association

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

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

Post (singular with capital) is the model

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.

Felix

I 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

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
includedhttp://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_functionhttp://ruby-doc.org/core/classes/Module.html#M001642)
"

so what do you spect the module method to return from i.module?

radhames brito wrote:

Post (singular with capital) is the model

that’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… :frowning: