Skip to content

Instantly share code, notes, and snippets.

@WassifAziz
Created September 5, 2012 15:04
Show Gist options
  • Save WassifAziz/3637979 to your computer and use it in GitHub Desktop.
Save WassifAziz/3637979 to your computer and use it in GitHub Desktop.
http://localhost:3000/locate/12/06/12/2012 returns as 2012-12-06
WANT IT TO RETURN AS
06-12-2012
======CONTROLLER====
def number_of_days
number_of_days = params[:number_of_days].to_i
if number_of_days <= 30
@days = days(number_of_days)
@locations = Location.all
else
redirect_to locate_path, alert: "TOO MANY DAYS!"
end
end
def specific_date
@user_date = params[:user_date].strptime('2001-02-03', '%Y-%m-%d')
# @user_date = Date.strftime("%Y-%m-%d")
end
protected
def days(number_of_days)
# Creates a list containing the next 7 dates from (and including) today.
days = []
for counter in 0..number_of_days
days << Date.today + counter
end
return days
end
end
===ROUTES=====
match "/locate/:number_of_days/*user_date" => "whens#specific_date"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment