Hi,
How I do a filter in a block of code?
example:
I have a block:
<% @notes[(0…3)].each do |note| %>
<%= notes.note %>
<%= notes.type %>
<% end %>
Type is a string, I would like to do a block filtering by a value on
type.
Thanks!
–
Fernando A.
Hi Fernando,
On Sun, Jun 5, 2011 at 3:59 PM, Fernando A.
[email protected] wrote:
Hi,
How I do a filter in a block of code?
example:
I have a block:
<% @notes[(0…3)].each do |note| %>
<% if notes.type.class == String %>
<%= notes.note %>
<%= notes.type %>
<% end %>
<% end %>
Type is a string, I would like to do a block filtering by a value on type.
However, your code will be much more testable if you do the filtering
on @notes in the controller, or even better, by writing a method in
your model that only returns records with type of class String.
HTH,
Bill
Thanks by the tip!
On Sun, Jun 5, 2011 at 6:06 PM, Bill W. [email protected]
wrote:
<li>
your model that only returns records with type of class String.
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
–
Fernando A.
[iOSDeveloper] - ObjectiveC
[WebDesigner] - CSS3&HTML5
[WebDeveloper] - RubyOnRails
*--------------------------------------------------------------
*
[portfolio] http://www.fernandoaureliano.com -
[blog]http://www.fernandoaureliano.com/