Hi all, I am a newbie trying to solve a simple IF statement problem in my
show view. The code below is all about the station attribute where it has
data which is either 'NMC' or 'NMN'. I want the view to show 'by new mill
central if 'NMC' is true, but this does not work well as sometimes it show
the wrong paragraph someone please help thanks
[code]
<p>
Station:
<% if @train_time.station = "NMC" == true %>
<p>By New Mills Central</p>
<% else %>
<p>By New Mills Newtown</p>
<% end %>
</p>
= ? AND weekday = ?", Time.now,Date::DAYNAMES[Date.today.wday]])
When this has to show 00:00:00 which is 12.00am it shows as nil and breaks
my app. So in the view i did this @bus_time.time.strftime("%H:%M") unless
@bus_time.time.nil?
There is no time of day class in ruby, the Time class (confusingly)
includes the date, which seems to be set to 2000-01-01 if only a time
of day is provided. Either you must cope with this in your
application or you must store the time of day in some other form such
as integer seconds into the day or as a string for example.
In the create action of the controller where you create your bus_time record, I would suggest you to do this . Please change the following code as per your application code.
There is no worry about creation as all i am trying to do is to read
information created from the database. I inputted the data via sql
statements which was quicker as i have so many records I will not be
creating any new records all I need to do is display it, but displaying all
those records is proving to be difficult as there are so many records and
scaffolding does is not appropriate for views I am getting:
monday time
monday time
monday time
tuesday time
tuesday time
tuesday time