Forum: Ruby on Rails trouble with routes...

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.
bearblu (Guest)
on 2009-02-17 02:04
(Received via mailing list)
I just started working with Rails 2.2.2 and I don't seem to be having
much luck with the new routing scheme.  When I try to edit a record
and save it I get and error message that looks as though it is trying
to use the id for the action. So just what am I doing wrong?

No action responded to 8. Actions: check_authorization, create,
destroy, edit, index, logged_in?, make_profile_vars, nav_link, new,
paginate, paginated?, param_posted?, protect, show, text_field_for,
and update
Jeff E. (Guest)
on 2009-02-17 02:06
(Received via mailing list)
Show us your action.
bearblu (Guest)
on 2009-02-17 02:15
(Received via mailing list)
The edit action is:

  def edit
    @title = "Pinnacle Harvest: Edit Vendor"
    @vendor = Vendor.find(params[:id])
  end

the update action is:

  def update
    raise params.inspect
    @vendor = Vendor.find(params[:id])

    respond_to do |format|
      if @vendor.update_attributes(params[:vendor])
        flash[:notice] = 'Vendor was successfully updated.'
        format.html { redirect_to :action => 'index' }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @vendor.errors, :status
=> :unprocessable_entity }
      end
    end
  end

the edit.html.erb file is:
<% form_for :vendor do |form| %>
<fieldset>
  <legend><%= @title %></legend>

  <%= error_messages_for 'vendor' %>
  <%= text_field_for form, "name" %>
  <%= text_field_for form, "city" %>
  <%= text_field_for form, "state" %>
  <%= text_field_for form, "zip_code", ZIP_CODE_LENGTH %>
  <%= text_field_for form, "phone_number" %>
  <%= text_field_for form, "fax_number" %>
  <%= text_field_for form, "web_url" %>

  <%= submit_tag "Update", :class => "new_client_vendor_submit" %>
</fieldset>
<% end %>

There is nothing fancy, I am pretty much a novice at Rails. ;-)

Rick
Jeff E. (Guest)
on 2009-02-17 03:53
(Received via mailing list)
That's a rather strange error considering you're not even trying to
redirect to :show after an update, but rather just :index.

Further strange are the actions it says are valid:
check_authorization, create,
destroy, edit, index, logged_in?, make_profile_vars, nav_link, new,
paginate, paginated?, param_posted?, protect, show, text_field_for,
and update

What is the URL that results in this error?  Do you have some other
plugins that might be adding these other actions?
bearblu (Guest)
on 2009-02-17 04:29
(Received via mailing list)
There are no plugins, I do have several gems installed... but you just
got me to thinking. Yep, it looks as though my code base got
corrupted.

Thanks,

Rick
Bharat R. (Guest)
on 2009-02-17 20:40
(Received via mailing list)
You need to show your routes.rb file as well.  This is the file that
routes requests to controllers and actions within them.
Bharat
This topic is locked and can not be replied to.