Hi,
I have hierarchical "if loops" like this
<% @descriptions.each_with_index do |description, i| %> <% description.tale2.each do |tax_ref| %>
<% if condition %>
<% if condition %> <% if condition %>
<%= $text_first_describe%> <%= $paren_author_yr %> <% ref_sp_uniq.each_with_index do |ref, i| %> <% if ref == tax_ref.ref_wo_brace%> <% execution %>
<% elsif i == (ref_sp_uniq.size - 1)%> <%# @ref_desc = "#{@ref_desc_numb}. #{tax_ref.ref_wo_brace}" %> <% end %> <% end %> <% if condition %> <% execution %>
<% elsif condition %> <% execution %> <% elsif taxon_name.emend_author_year %>
<%= print %> <% else %>
<%= print %>
<% end %> <% end %> <% else %> <% if condition %> <%= print %> <% ref_sp_uniq.each_with_index do |ref, i| %> <% if condition %> <% execution %>
<% elsif condition %> <% execution %>
<% end %> <% end %> <% if condition %> <% execution %>
<% elsif condition %> <% execution %>
<% elsif condition %> <% execution %>
<% else %> <% execution %>
<% end %> <% end %> <% end %> <% end %> <% end %>
<% end %>
Hi Palani... first thing is find a way to move your logic to the Model. Your html.erb code really should be as much as possible just to present your data. Secondly, using the 'case' construction might help:
a = 1
case somthing
when 'x':
do somthing
when 'y'
do something else
when 'z'
do another thing....
....
end
--Kindly suggest me possible way to reduce this kind of junk "if loops".
--With Regards,
Palani Kannan. K,
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@googlegroups.com.
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.
--
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@googlegroups.com.
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.
No comments:
Post a Comment