charlie bowman
2006-Jan-04 01:36 UTC
[Rails] help with link_to_if, I can''t make it work...
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"}) %> -- Posted via http://www.ruby-forum.com/.
charlie bowman
2006-Jan-04 04:05 UTC
[Rails] Re: help with link_to_if, I can''t make it work...
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"}) %>-- Posted via http://www.ruby-forum.com/.
Lieven De Keyzer
2006-Jan-04 12:36 UTC
[Rails] Re: help with link_to_if, I can''t make it work...
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? -- Posted via http://www.ruby-forum.com/.
charlie bowman
2006-Jan-04 12:42 UTC
[Rails] Re: help with link_to_if, I can''t make it work...
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: <span class="post_date"> commented...</span><br /> 19: <div class="comment"><%= strip_tags(comment.comment) %></div><br /> 20: <%= link_to_if(comment.web_site.length > 0, comment.name, 21: comment.web_site {"class" => "comment_by"}) %> 22: <% end %> 23: <h3>Comment Form</h3> 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?-- Posted via http://www.ruby-forum.com/.
Lieven De Keyzer
2006-Jan-04 12:44 UTC
[Rails] Re: help with link_to_if, I can''t make it work...
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: <span class="post_date"> commented...</span><br > /> > 19: <div class="comment"><%= > strip_tags(comment.comment) %></div><br /> > 20: <%= link_to_if(comment.web_site.length > 0, > comment.name, > 21: comment.web_site {"class" => "comment_by"}) %> > 22: <% end %> > 23: <h3>Comment Form</h3> > 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"}) %> -- Posted via http://www.ruby-forum.com/.
charlie bowman
2006-Jan-04 22:21 UTC
[Rails] Re: help with link_to_if, I can''t make it work...
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"}) %>-- Posted via http://www.ruby-forum.com/.