Dear All, I need to apply a regular expression in html.erb <% taxon_name.strains.each do |strain| %> <% taxon_name.strain_appendices.each_with_index do |strain_appendice, i| %> *<% if ((strain_appendice.data_source =~ /LPSN/) && (strain.relevance =~ /^ty(.*)ain$/))%>* <% if i == 0 %> <p><%= strain_appendice.appendix %> </p> <% strain.strain_id %> <% strain.relevance %> <%else%> <%= strain_appendice.appendix %> - <% strain.strain_id %> <% strain.relevance %> <%end%> <%end%> This code replaces the all content of a strain.strain_id & strain.relevance and doesnot passes match criteria. Instead of matching it replacing strain.strain_id & strain.relevance contents. Kindly tell me the way to match and pass conditions. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 15 October 2010 13:42, PalaniKannan K <kpalanikannan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Dear All, > > I need to apply a regular expression in html.erb > > <% taxon_name.strains.each do |strain| %> > <% taxon_name.strain_appendices.each_with_index do |strain_appendice, i| %> > <% if ((strain_appendice.data_source =~ /LPSN/) && (strain.relevance =~ > /^ty(.*)ain$/))%> > <% if i == 0 %> > <p><%= strain_appendice.appendix %> </p> <% strain.strain_id %> <% > strain.relevance %> > <%else%> > <%= strain_appendice.appendix %> - <% strain.strain_id %> <% > strain.relevance %> > <%end%> > <%end%> > > This code replaces the all content of a strain.strain_id & strain.relevance > and doesnot passes match criteria. Instead of matching it replacing > strain.strain_id & strain.relevance contents.Most of this logic should be in the controller not the view, just pass the data needed for display to the view. I suggest you move it to the controller, where the logic will be much easier to read, and see what happens then. If it is still not working you can debug it using ruby-debug to find where it is going wrong. See the Rails Guide on debugging if you do not know how to do this. Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
Dear Collin, Thank you. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Having said that the logic should be in the controller I thought I would point out a couple of errors in your code anyway so you may understand more what was happening. On 15 October 2010 20:49, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 15 October 2010 13:42, PalaniKannan K <kpalanikannan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> Dear All, >> >> I need to apply a regular expression in html.erb >> >> <% taxon_name.strains.each do |strain| %> >> <% taxon_name.strain_appendices.each_with_index do |strain_appendice, i| %> >> <% if ((strain_appendice.data_source =~ /LPSN/) && (strain.relevance =~ >> /^ty(.*)ain$/))%> >> <% if i == 0 %> >> <p><%= strain_appendice.appendix %> </p> <% strain.strain_id %> <% >> strain.relevance %>Those <% should be <%= and did you mean the second two to be after </p>?>> <%else%> >> <%= strain_appendice.appendix %> - <% strain.strain_id %> <% >> strain.relevance %><%= again. I note no p tags this time. Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.