Bugs: Browse | Submit New | Admin

[#7919] Leading/trailing spaces in ingredient quantities prevent recipe display

Date:
2007-01-17 05:06
Priority:
3
Submitted By:
Bob Apthorpe (apthorpe)
Assigned To:
Nobody (None)
Category:
None
State:
Open
Summary:
Leading/trailing spaces in ingredient quantities prevent recipe display

Detailed description
recipe/show fails if there are leading spaces in ingredient quantities:

ActionView::TemplateError (private method `split' called for nil:NilClass) on line
#55 of app/views/recipe/show.rhtml:
52:                             if tmp_qty =~ /\//
53:                                 if tmp_qty.include?(" ")
54:                                     qty_str += tmp_qty.split(" ")[0]
55:                                     qty_str += " <sup>#{tmp_qty.split("
")[1].split("/")[0]}</sup>/<sub>#{tmp_qty.split("
")[1].split("/")[1]}</sub>"
56:                                 else
57:                                     qty_str = "<sup>#{tmp_qty.split("/")[0]}</s
up>/<sub>#{tmp_qty.split("/")[1]}</sub>"
58:                                 end

I worked around this by adding a 'tmp_qty.strip' after line 52. Ideally the leading and trailing spaces would never
be stored in the database, so the real fix should occur when ingredient quantities are accepted from the user or before
they are saved.

Add A Comment: Notepad

Please login


Followup

No Followups Have Been Posted

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

No Changes Have Been Made to This Item