Forum: Ruby on Rails form_tag error -- not found, 404 -- action DOES exist!

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2837408ba0375c40b235f0a5a5107d37?d=identicon&s=25 doug (Guest)
on 2006-03-06 11:42
Hi -- I've got a very strange error.
I have an action called 'commit_input' on a controller called
'SiteVisitController'. This definately exists, and is called from the
functional test for it, and passes fine.
My problem is with the form that is supposed to call this action.
The form tag is:

<%= form_tag({:action=>'commit_input'}) %>

<%# various controls -- listed in full below -%>

<%= submit_tag 'commit' %>
<%= end_form_tag %>

When this is run, I get the page cannot be found screen, and the
following error in webrick's console:

127.0.0.1 - - [06/Mar/2006:10:37:30 GMT Standard Time] "GET
/site_visit/input/1
HTTP/1.1" 200 153359
http://localhost:3000/admin/visit_data -> /site_visit/input/1
#<NoMethodError: undefined method `update' for "0":String>
["c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/cgi_ext/
cgi_methods.rb:116:in `build_deep_hash'",
"c:/ruby/lib/ruby/gems/1.8/gems/action
pack-1.9.1/lib/action_controller/cgi_ext/cgi_methods.rb:116:in
`build_deep_hash'
",
"c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/cgi_ex
t/cgi_methods.rb:41:in `parse_request_parameters'",
"c:/ruby/lib/ruby/gems/1.8/g
ems/actionpack-1.9.1/lib/action_controller/cgi_ext/cgi_methods.rb:39:in
`each'",
 "c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/cgi_ext/
cgi_methods.rb:39:in `parse_request_parameters'",
"c:/ruby/lib/ruby/gems/1.8/gem
s/actionpack-1.9.1/lib/action_controller/cgi_process.rb:74:in
`request_parameter
s'",
"c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/requ
est.rb:8:in `parameters'",
"c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/
action_controller/base.rb:734:in `assign_shortcuts'",
"c:/ruby/lib/ruby/gems/1.8
/gems/actionpack-1.9.1/lib/action_controller/base.rb:351:in `process'",
"c:/ruby
/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/rescue.rb:20:in
`
process_with_exception'",
"c:/ruby/lib/ruby/gems/1.8/gems/rails-0.13.1/lib/dispa
tcher.rb:34:in `dispatch'",
"c:/ruby/lib/ruby/gems/1.8/gems/rails-0.13.1/lib/web
rick_server.rb:105:in `handle_dispatch'",
"c:/ruby/lib/ruby/gems/1.8/gems/rails-
0.13.1/lib/webrick_server.rb:71:in `service'",
"c:/ruby/lib/ruby/1.8/webrick/htt
pserver.rb:104:in `service'",
"c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in
`run'", "c:/ruby/lib/ruby/1.8/webrick/server.rb:155:in `start_thread'",
"c:/ruby
/lib/ruby/1.8/webrick/server.rb:144:in `start'",
"c:/ruby/lib/ruby/1.8/webrick/s
erver.rb:144:in `start_thread'",
"c:/ruby/lib/ruby/1.8/webrick/server.rb:94:in `
start'", "c:/ruby/lib/ruby/1.8/webrick/server.rb:89:in `each'",
"c:/ruby/lib/rub
y/1.8/webrick/server.rb:89:in `start'",
"c:/ruby/lib/ruby/1.8/webrick/server.rb:
79:in `start'", "c:/ruby/lib/ruby/1.8/webrick/server.rb:79:in `start'",
"c:/ruby
/lib/ruby/gems/1.8/gems/rails-0.13.1/lib/webrick_server.rb:57:in
`dispatch'", "s
cript/server:49"]
[2006-03-06 10:37:37] ERROR `/site_visit/commit_input' not found.
127.0.0.1 - - [06/Mar/2006:10:37:37 GMT Standard Time] "POST
/site_visit/commit_
input HTTP/1.1" 404 293
http://localhost:3000/site_visit/input/1 -> /site_visit/commit_input

I have been trying to fix this for a couple of days, now, and have tried
everything I can think of, including explicitly stating the controller
in the form tag, renaming the action, etc.
Has anyone else come accross (& hopefully solved) this problem?
If anyone can shed any light, I would be immensely grateful.
I'll post the full form code at the bottom of this post.
Thanks for any & all help,
   doug.



<table>
    <tr>
        <th>SI UPRN</th>
        <th>School Name</th>
        <th>Address 01</tr>
        <th>Postcode</th>
    </tr>
    <tr>
        <td>
            <%= @property.si_uprn %>
        </td>
        <td>
            <%= @property.name %>
        </td>
        <td>
            <%= @property.address1 %>
        </td>
        <td>
            <%= @property.address_postcode %>
        </td>
    </tr>
</table>

<%= form_tag({:action=>'commit_input'}) %>

<table>
    <caption>Site Visit Times</caption>
    <tr>
        <th>Surveyor</th>
        <th>Date</th>
        <th>Time Arrived</th>
        <th>Time Left</th>
    </tr>
    <% i=0 -%>
    <% @site_visit_helper.timesheet_records.each do |tr| -%>
        <tr>
            <td>
                <%=
select_tag("site_visit_helper[timesheet_records][#{i.to_s}][surveyor_id]",
                        options_for_select(@surveyors, tr.surveyor_id))
%>
            </td>
            <td>
                <%= select_date(
	                    hash2date(tr.visited_on),
	                    :prefix=>"site_visit_helper[timesheet_records][#{i.to_s}][visited_on]",
	                    :include_blank=>true) %>
            </td>
            <td>
                <%= select_time(
                        hash2time(tr.arrived_at),
                        :prefix=>"site_visit_helper[timesheet_records][#{i.to_s}][arrived_at]",
                        :include_blank=>true,
                        :minute_step=>5) %>
            </td>
            <td>
                <%= select_time(
                        hash2time(tr.left_at),
                        :prefix=>"site_visit_helper[timesheet_records][#{i.to_s}][left_at]",
                        :include_blank=>true,
                        :minute_step=>5) %>
            </td>
        </tr>
        <% i+=1 -%>
    <% end -%>
</table>

<table>
    <caption>Photographs</caption>
    <tr>
        <th>Date</th>
        <th>Card Number</th>
        <th>First Photo Number</th>
        <th>Last Photo Number</th>
    </tr>
    <% i=0 -%>
    <% @site_visit_helper.photosheet_records.each do |pr| -%>
        <tr>
            <td>
                <%= select_date(
	                    hash2date(pr.taken_on),
	                    :prefix=>"site_visit_helper[photosheet_records][#{i.to_s}][taken_on]",
	                    :include_blank=>true) %>
            </td>
            <td>
                <%= text_field_tag(
                        "site_visit_helper[photosheet_records][#{i.to_s}][card_number]",
                        pr.card_number) %>
            </td>
            <td>
                <%= text_field_tag(
                        "site_visit_helper[photosheet_records][#{i.to_s}][first_photo_number]",
                        pr.first_photo_number) %>
            </td>
            <td>
                <%= text_field_tag(
                        "site_visit_helper[photosheet_records][#{i.to_s}][last_photo_number]",
                        pr.last_photo_number) %>
            </td>
        </tr>
        <% i+=1 -%>
    <% end -%>
</table>

<table>
    <caption>Customer Sign Off</caption>
    <tr>
        <th>Name</th>
        <th>Position</th>
        <th>Man Days</th>
    </tr>
    <tr>
        <td>
            <%= text_field(:site_visit_helper, :customer_sign_off_name)
%>
        </td>
        <td>
            <%= text_field(:site_visit_helper,
:customer_sign_off_position) %>
        </td>
        <td>
            <%= text_field(:site_visit_helper, :man_days) %>
        </td>
    </tr>
    <tr>
        <th colspan="2">Date</th>
        <th>Non Site Time</th>
    </tr>
    <tr>
        <td colspan="2">
            <%= select_date(hash2date(
                    @site_visit_helper.customer_sign_off_date),
                    :prefix=>"site_visit_helper[customer_sign_off_date]",
                    :include_blank=>true) %>
        </td>
        <td>
            <%= text_field(:site_visit_helper, :non_site_time) %>
        </td>
    </tr>
</table>

<table>
    <caption>Sketch Index</caption>
    <tr>
        <td>
            <%= text_area(:site_visit_helper, :sketch_index, :cols=>50,
:rows=>10) %>
        </td>
    </tr>
</table>

<table>
    <caption>Surveyor Sign Off</caption>
    <tr>
        <th>Surveyor</th>
        <th>Comments</th>
    </tr>
    <tr>
        <td>
            <%= select_tag(:site_visit_helper,
options_for_select(@surveyors)) %>
        </td>
        <td rowspan="3">
            <%= text_area(:site_visit_helper, :comments, :cols=>38,
:rows=>5) %>
        </td>
    </tr>
    <tr>
        <th>
            Date
        </th>
    </tr>
    <tr>
        <td>
            <%= select_date(hash2date(
                    @site_visit_helper.sign_off_date),
                    :prefix=>"site_visit_helper[sign_off_date]",
                    :include_blank=>true) %>
        </td>
    </tr>
    <tr>
        <td>
        </td>
        <td>
            <%= submit_tag 'commit' %>
        </td>
    </tr>
</table>

<%= end_form_tag %>
2837408ba0375c40b235f0a5a5107d37?d=identicon&s=25 doug (Guest)
on 2006-03-06 21:22
Hi -- sorry if this is bad practice (lemme know & I'll take it on
board), but I'm bumping this post as I'm really struggling to find a
solution to my problem. Someone seemed to have this same thing in a
chatroom once, but apparently took the conversation aside, so I couldn't
follow it to a solution!
   doug.
C64e63b70be7dfed8b0742540b8b27e5?d=identicon&s=25 Mark Reginald James (Guest)
on 2006-03-07 05:30
(Received via mailing list)
doug wrote:

> http://localhost:3000/admin/visit_data -> /site_visit/input/1
> #<NoMethodError: undefined method `update' for "0":String>
> ["c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/cgi_ext/
> cgi_methods.rb:116:in `build_deep_hash'",

You're using Rails 0.13.1.  Are you able to upgrade to 1.0?
Also, include an example of the params hash as POSTed.

--
We develop, watch us RoR, in numbers too big to ignore.
This topic is locked and can not be replied to.