I actually got a little better. I updated the search2_controller.rb
index method code with this:
def index
if request.post?
@origin_place = params[:city][:namestate]
@destination_place = params[:city][:namestate]
redirect_to({ :action => "map_places", :origin_place =>
@origin_place,
:destination_place =>
@destination_place, })
end
end
Now I am able to get the origin_place. However, destination_place is
the same as origin_place. The URL generated by the clicking the Submit
button is:
http://localhost:3001/search2/map_places?destination_place=Ambler%2C+PA&origin_place=Ambler%2C+PA
How come is it returning the same city name for both origin and
destination ?
Thanks,
Nick,
On Mar 5, 8:50 pm, "Nick" <[EMAIL PROTECTED]> wrote:
> Thanks for your answer. I'm new to ruby and here is my code:
>
> index.rhtml:
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml">
> <head>
> <meta http-equiv="content-type" content="text/html; charset=utf-8"/
>
> <title>Mezzoo.com</title>
>
> <%= javascript_include_tag :defaults %>
>
> </head>
> <body>
>
> <h1>Input Places</h1>
> <fieldset>
> <% form_tag do %>
> <p>
> <label for="search2_origin_place">Origin Place:</
> label>
> <%= text_field_with_auto_complete :city, :namestate %>
> </p>
> <p>
> <label for="search2_destination_place">Destination
> Place:</label>
> <%= text_field_with_auto_complete :city, :namestate %>
> </p>
> <p>
> <%= submit_tag "Start Search" %>
> </p>
> <% end %>
> </fieldset>
> </body>
> </html>
>
> -------------------------------------
> here is the controller code for search2_controller.rb:
>
> class Search2Controller < ApplicationController
>
> auto_complete_for :city, :namestate
>
> def index
>
> if request.post?
> @origin_place = params[:origin_place]
> @destination_place = params[:destination_place]
> redirect_to({ :action => "map_places", :origin_place =>
> @origin_place,
> :destination_place =>
> @destination_place, })
> end
>
> end
>
> def map_places()
>
> @origin_place = params[:origin_place]
> @destination_place = params[:destination_place]
>
> end
>
> end
>
> ------------------------------
>
> Here is the code for map_places.rhtml:
>
> <h1>Map Places</h1>
>
> <p>
> Origin Place: <%= @origin_place %>
> </p>
>
> <p>
> Destination Place: <%= @destination_place %>
> </p>
>
> ---------------
>
> I must be missing something easy.
>
> Thanks,
>
> On Mar 5, 3:01 am, Christophe Porteneuve <[EMAIL PROTECTED]> wrote:
>
> > Hey Nick,
>
> > Nick a ?crit :
>
> > > I created a form with 2 text_field_with_auto_complete fields and a
> > > submit button. I am able to get the auto complete feature to work.
> > > However, I am unable to read the values of the two text fields when I
> > > click the submit button. The classic way with @varname =
> > > params[:field_value] does not seem to work.
>
> > m'kkayyy, basic questions first:
>
> > - Are your fields indeed *in* the form you're submitting, DOM-wise?
> > - Did you make sure they were provided with a non-empty name= attribute?
> > - At submission time, are they deemed successful (e.g. enabled, in this
> > case)?
>
> > If all this fails, two more paths:
>
> > - Hook a handler to the form's submit event and console.log or alert its
> > serialize() method result. Check for your fields.
> > - Post the details of your form opening and helper calls, in template
> > order, in this thread... Maybe we'll see something you forgot to mention.
>
> > --
> > Christophe Porteneuve a.k.a. TDD
> > "[They] did not know it was impossible, so they did it." --Mark Twain
> > Email: [EMAIL PROTECTED]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---