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

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:

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:

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. 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, 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?