In controller #for exampleday:hour:min @sd_resol = ServiceDeskResolutionEffort.new(“1:22:10”)
Here HOW CAN I IMPLEMENT VALIDATION THAT HOUR NOT GREATER THAN 23 AND
MINUTE NOT GREATER HAN 59 AND ALSO CHECK NON NUMERIC CHARACTERS NOT TO
BE ENTERED ALL THESE DAY:HOUR:MINUTE
Sorry sir A change is there i need the vallidation when i save …My
controller as
def sd_resolution_save
@sd_effort=params[:sd_resol][:days]+’:’+params[:sd_resol][:hours]+’:’+params[:sd_resol][:minutes]
@sd_resolution_id=params[:sd_resolution_id]
if @sd_resolution_id==nil
@service_desk_resolution=ServiceDeskResolution.new(params[:sd_resolution])
@service_desk_resolution.effort=@sd_effort @service_desk_resolution.save
else
@sd_ticket_resolution=ServiceDeskResolution.find @sd_resolution_id @sd_ticket_resolution.update_attribute(:effort,@sd_effort)
@update_sd_ticket_resolution=@sd_ticket_resolution.update_attributes(params[:sd_resolution])
end
redirect_to :action => ‘show_details’, :id => params[:id]
end
HERE BEFORE SAVING @service_desk_resolution.effort I NEED
VALIDATION…ALL THE OTHER SAME AS MY PROBLEM…AND PLEASE TELL ME HOW TO
CAPTURE THAT ERROR(IF EXISTS ALSO…Here ServiceDeskResolution is an
active record class
nil || /^(\d)(\d)$/.match(seconds) == nil
raise “Please enter the numeric value in time.”
elsif hours.to_i > 23 || minutes.to_i > 59 || seconds.to_i > 59
raise “Please enter the right rage of values.”
else @hours = hours @minutes = minutes @seconds = seconds
end
rescue
puts $!
end
end
attr_reader :minutes
In the view #for exampleday:hour:min
–
Thanks & Regards,
Pavan A.
NOTICE : This transmission contains information that may be confidential
and
that may also be privileged. Unless you are the intended recipient of
the
message or authorized to receive it for the intended recipient, you may
not
copy, forward, or otherwise use it, or disclose it or its contents to
anyone
else. If you have received this transmission in error please notify us
immediately and delete it from your system.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.