html - Rails nested list with concat content_tag in Helper -
i'm trying create similar this: using helpers in rails 3 output html
here's helper:
def section_references_to_html (section) concat content_tag (:ol, :class => 'sources') section.references.each |reference| concat content_tag (:li,content_tag(:a, reference.text, :src => reference.url)) end end end
but it's returning sorts of syntax errors:
/~/app/helpers/application_helper.rb:21: syntax error, unexpected ',', expecting ')' concat content_tag (:ol, :class => 'sources') ^ /~/app/helpers/application_helper.rb:21: syntax error, unexpected ')', expecting keyword_end concat content_tag (:ol, :class => 'sources') ^ /~/app/helpers/application_helper.rb:22: syntax error, unexpected keyword_do_block, expecting keyword_end section.references.each |reference| ^ /~/app/helpers/application_helper.rb:23: syntax error, unexpected tidentifier, expecting keyword_do or '{' or '(' concat content_tag (:li,content_tag(:a, referen... ^ /~/app/helpers/application_helper.rb:23: syntax error, unexpected ',', expecting ')' ... concat content_tag (:li,content_tag(:a, reference.tex... ... ^ /~/app/helpers/application_helper.rb:23: syntax error, unexpected ')', expecting keyword_end
what doing wrong here? maybe using partial better.
the main problem have spaces between content_tag
, (
. try this:
def section_references_to_html(section) content_tag(:ol, class: 'sources') section.references.each |reference| content_tag(:li, content_tag(:a, reference.text, href: reference.url)) end end end
Comments
Post a Comment