This gist shows the current state of a rails app I'm working on. I'm attempting to figure out the routing so that when a user submits a zipcode into the form on app/views/forecast/index.html.erb
they get the same experience as if they had done http://localhost:3000/forecast/87120
.
There are two main issues that I believe I am misunderstanding.
-
How can I make the default param with forecast routing be
:zip
instead of:id
? (Is it possible for me to just useresources :forecast
in theroutes.rb
file?) -
How do I properly redirect things when I know that the
params[:zip].blank?
is not true so that theshow
method/action of theforecast
controller is sent the message.
I understand that I can just change my controller to behave with a params[:id]
instead of params[:zip]
, but I feel that there is a piece I'm missing here, and it still doesn't help me with my redirect after form submission on the index.html.erb
page.
Routes:
Controller:
View: