For the life of me I can’t get it to work. Here is an example of my
syntax. I’m trying to make comment.name a link to comment.web_site only
if there is a comment.web_site. Can someone please help?
<%= link_to_if(comment.web_site.length > 0, comment.name,
comment.web_site {“class” => “comment_by”}) %>
has anyone else tried to use link_to_if?
charlie bowman wrote:
For the life of me I can’t get it to work. Here is an example of my
syntax. I’m trying to make comment.name a link to comment.web_site only
if there is a comment.web_site. Can someone please help?
<%= link_to_if(comment.web_site.length > 0, comment.name,
comment.web_site {“class” => “comment_by”}) %>
yes, here they are.
ActionView::TemplateError (compile error
script/…/config/…/app/views/journal/view.rhtml:21: syntax error
comment.web_site {“class” => “comment_by”}) ).to_s); _erbout.concat
“\r\n”
^) on line #21 of
app/views/journal/view.rhtml:
18: commented…
19:
<%=
strip_tags(comment.comment) %>
20: <%= link_to_if(comment.web_site.length > 0,
comment.name,
21: comment.web_site {“class” => “comment_by”}) %>
22: <% end %>
23:
Comment Form
24: <%= start_form_tag(:action => “save_comment”, :id =>
@post.id) %>
Lieven De Keyzer wrote:
charlie bowman wrote:
For the life of me I can’t get it to work. Here is an example of my
syntax. I’m trying to make comment.name a link to comment.web_site only
if there is a comment.web_site. Can someone please help?
<%= link_to_if(comment.web_site.length > 0, comment.name,
comment.web_site {“class” => “comment_by”}) %>
Do you get errors? Other resulst as the ones you expect?
charlie bowman wrote:
yes, here they are.
ActionView::TemplateError (compile error
script/…/config/…/app/views/journal/view.rhtml:21: syntax error
comment.web_site {“class” => “comment_by”}) ).to_s); _erbout.concat
“\r\n”
^) on line #21 of
app/views/journal/view.rhtml:
18: commented…
19:
<%=
strip_tags(comment.comment) %>
20: <%= link_to_if(comment.web_site.length > 0,
comment.name,
21: comment.web_site {“class” => “comment_by”}) %>
22: <% end %>
23: Comment Form
24: <%= start_form_tag(:action => “save_comment”, :id => @post.id) %>
Lieven De Keyzer wrote:
charlie bowman wrote:
For the life of me I can’t get it to work. Here is an example of my
syntax. I’m trying to make comment.name a link to comment.web_site only
if there is a comment.web_site. Can someone please help?
<%= link_to_if(comment.web_site.length > 0, comment.name,
comment.web_site {“class” => “comment_by”}) %>
Do you get errors? Other resulst as the ones you expect?
Well, it seems like you’ve forgotten a comma.
Try:
<%= link_to_if(comment.web_site.length > 0, comment.name,
comment.web_site ----->,<------ {“class” =>
“comment_by”}) %>
charlie bowman wrote:
For the life of me I can’t get it to work. Here is an example of my
syntax. I’m trying to make comment.name a link to comment.web_site only
if there is a comment.web_site. Can someone please help?
<%= link_to_if(comment.web_site.length > 0, comment.name,
comment.web_site {“class” => “comment_by”}) %>
Do you get errors? Other resulst as the ones you expect?
That worked like a charm! Thanks for the help!
Lieven De Keyzer wrote:
Try:
<%= link_to_if(comment.web_site.length > 0, comment.name,
comment.web_site ----->,<------ {“class” =>
“comment_by”}) %>