How do I seach for this in the api?

<% for product in @products %>
<%= h(product.description) %>

It is simple code I see, but it has no umm classes I think

<% for product <-- that can be fish in @products <-- this is the table
I know %>

      <%= h(product <-- so this can be fish as well .description<-- 

this is the object to show the table field) %>

But what would <% for() _ in @() %> be called… Sorry if this is
confusing

Yes, it is confusing…but I’ll give it a try.

You’re talking about loops. Since these are part of the Ruby language
and
not Rails you’ll find information about them in the ruby-doc.org

Looking at your example I think you might want to try:
<% @products.each do |product| %>
<%= h(product.description) %>
<% end %>

‘product’ in this case can be anything…fish, or potatos, or whatever
as
long as it has the method called description you’ll be good to go.
If you want to find out what kind of object product is (assuming you
have an
mixed array of different types of objects)
<%= h(product.class) %>
AND if you want to really get crazy you can look at the class of the
object
in your array and render different partials for each class

-Brian

Brian Chamberlain wrote:

Yes, it is confusing…but I’ll give it a try.

You’re talking about loops. Since these are part of the Ruby language
and
not Rails you’ll find information about them in the ruby-doc.org

Looking at your example I think you might want to try:
<% @products.each do |product| %>
<%= h(product.description) %>
<% end %>

‘product’ in this case can be anything…fish, or potatos, or whatever
as
long as it has the method called description you’ll be good to go.
If you want to find out what kind of object product is (assuming you
have an
mixed array of different types of objects)
<%= h(product.class) %>
AND if you want to really get crazy you can look at the class of the
object
in your array and render different partials for each class

-Brian

Yikes, Everyone should reallly really I mean really just learn Ruby
before they get far into Rails… It does not help having to walk miles
backwards just to go get your keys again…

Are you going to take your own advice?

I don’t see why a person can’t do both at the same time.

-Brian

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs