I''m having some trouble with styling my views. Here is a particular snippet that I think illustrates well: <p><%= @tour_request.booked_datetime ? "<strong>Confirmed For:</strong> <span class="red">#{@tour_request.booked_datetime_string}</span> ":"<strong>Date and time requested:</strong> #{@tour_request.daterequested} | #{@tour_request.preferredtime_string} <strong>Alternative date and time requested:</strong> #{@tour_request.altdaterequested} #{@tour_request.preferredtime_string}" %></p> That will prevent the page from loading, showing a custom error screen. But this, will display fine: <p><%= @tour_request.booked_datetime ? "<strong>Confirmed For:</strong> <strong>#{@tour_request.booked_datetime_string}</strong> ":"<strong>Date and time requested:</strong> #{@tour_request.daterequested} | #{@tour_request.preferredtime_string} <strong>Alternative date and time requested:</strong> #{@tour_request.altdaterequested} #{@tour_request.preferredtime_string}" %></p> The only difference is on the first example I had <span class="red">#{@tour_request.booked_datetime_string}</span> and the second I had <strong>#{@tour_request.booked_datetime_string}</strong> I know I could just do <span class="red"><%@tour_request.booked_datetime_string %> but this field won''t always be displaying, so I need to find a way to make whichever that particular tour has filled out showing, whether it''s booked_datetime_string, tour_request.daterequested, preferredtime_string or altdaterequested Would appreciate any help! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 6 Jan 2009, at 20:54, Ryan Ororie wrote:> > I''m having some trouble with styling my views. > > Here is a particular snippet that I think illustrates well: > > <p><%= @tour_request.booked_datetime ? "<strong>Confirmed For:</ > strong> > <span class="red">#{@tour_request.booked_datetime_string}</span> > ":"<strong>Date and time requested:</strong> > #{@tour_request.daterequested} | #{@tour_request.preferredtime_string} > <strong>Alternative date and time requested:</strong> > #{@tour_request.altdaterequested} > #{@tour_request.preferredtime_string}" > %></p> > > That will prevent the page from loading, showing a custom error > screen.At a basic level that code boils down to "blahblahblah"red"blabblahblah" which isn''t syntactically correct (quotes in strings need to be escaped) Fred> > > But this, will display fine: > > <p><%= @tour_request.booked_datetime ? "<strong>Confirmed For:</ > strong> > <strong>#{@tour_request.booked_datetime_string}</strong> > ":"<strong>Date > and time requested:</strong> #{@tour_request.daterequested} | > #{@tour_request.preferredtime_string} <strong>Alternative date and > time > requested:</strong> #{@tour_request.altdaterequested} > #{@tour_request.preferredtime_string}" %></p> > > The only difference is on the first example I had <span > class="red">#{@tour_request.booked_datetime_string}</span> and the > second I had <strong>#{@tour_request.booked_datetime_string}</strong> > > I know I could just do <span class="red"><%> @tour_request.booked_datetime_string %> but this field won''t always be > displaying, so I need to find a way to make whichever that particular > tour has filled out showing, whether it''s booked_datetime_string, > tour_request.daterequested, preferredtime_string or altdaterequested > > Would appreciate any help! > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I think the first doublequote around "red" is terminating the string in the first part of your ? : expresion. If it were me, I''d verbose that out some: <% if @tour_request.booked_datetime then %> <p> <span class="label">Confirmed For:</span> <%= @tour_request.booked_datetime %> </p> <% else %> <p> <span class="label">Date and time requested:</span> <%= @tour_request.daterequested %> </p> <% end %> That way you''re not so much mixing the markup & the ruby, which always winds up confusing me. Also--having .booked_datetime and .booked_datetime_string methods seems odd--consider writing a format_date helper to use to make dates pretty if you need to get fancy. HTH, -Roy -----Original Message----- From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-talk@googlegroups.com] On Behalf Of Ryan Ororie Sent: Tuesday, January 06, 2009 12:55 PM To: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Subject: [Rails] Styling rails elements I''m having some trouble with styling my views. Here is a particular snippet that I think illustrates well: <p><%= @tour_request.booked_datetime ? "<strong>Confirmed For:</strong> <span class="red">#{@tour_request.booked_datetime_string}</span> ":"<strong>Date and time requested:</strong> #{@tour_request.daterequested} | #{@tour_request.preferredtime_string} <strong>Alternative date and time requested:</strong> #{@tour_request.altdaterequested} #{@tour_request.preferredtime_string}" %></p> That will prevent the page from loading, showing a custom error screen. But this, will display fine: <p><%= @tour_request.booked_datetime ? "<strong>Confirmed For:</strong> <strong>#{@tour_request.booked_datetime_string}</strong> ":"<strong>Date and time requested:</strong> #{@tour_request.daterequested} | #{@tour_request.preferredtime_string} <strong>Alternative date and time requested:</strong> #{@tour_request.altdaterequested} #{@tour_request.preferredtime_string}" %></p> The only difference is on the first example I had <span class="red">#{@tour_request.booked_datetime_string}</span> and the second I had <strong>#{@tour_request.booked_datetime_string}</strong> I know I could just do <span class="red"><%= @tour_request.booked_datetime_string %> but this field won''t always be displaying, so I need to find a way to make whichever that particular tour has filled out showing, whether it''s booked_datetime_string, tour_request.daterequested, preferredtime_string or altdaterequested Would appreciate any help! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---