Subject: Trying to Get Results from Form Element

I am trying to create an application loosely based on the Depot
application
presented in Agile Web D. with Rails (AWDwR). I am using the
folowing controllers:

admin_Controller
application_Controller
city_map_controller (with method: displayGMap)

== Code Extract from city_map_controller ==

Show a Google Map on a new page

def displayGMap

@mapPoint = Gmap.find(params[:id])

DBUG: Go back with report of what we found

redirect_to_index(“What the form got: |#{params[:id]}|
|#{params[:mapPoint]}|”)

if params[:context] == :embedded
render(:layout => false,
:locals => { :mapPoint => @mapPoint})
end
end

I am using the following model:

gmap.rb (containing class Gmap < ActiveRecord::Base)

with the following views:

city_map (containing displayGMap.rhtml, index.rhtml)
layouts (containing city_map.rhtml)

Everything starts well. I display a page (city_map/index.rhtml) with a
form to select
a map point. When I get to the “action” method (displayGMap) I find
that I don’t
have access to the results of my selection. In fact, I’m not certain
what I have.
I tried to use statements like the ones in AWDwR book to extract params
values,
but only get nil. Now I’m confused. How can I see what is passed into
the action method?
How can I understand what the Action Controller is trying to tell me?

== Messages from Rails Action Controller ==
ActiveRecord::RecordNotFound in CitymapController#displayGMap
Couldn’t find Gmap without an ID

Request
Parameters: {“commit”=>“Show Map”, “mapPoint”=>{“id”=>“5”}}

==Code Extract from index.rhtml==
<%= start_form_tag( :action => “displayGMap” ) %>
<% mapPoints = Gmap.allMapPoints() -%>
<%= cityList = mapPoints.map { |m| [m.description, m.id] }
select(“mapPoint”, “id”, cityList) %>
<%= submit_tag( “Show Map” ) %>

By the Way -
When I hard code the parameter value i.e. @mapPoint = Gmap.find(5),
everything works fine.

let try: mapPoint[:id]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs