Trouble with routes


#1

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


#2

Show us your action.


#3

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| %>

<%= @title %>

<%= 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” %>

<% end %>

There is nothing fancy, I am pretty much a novice at Rails. :wink:

Rick


#4

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?


#5

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


#6

You need to show your routes.rb file as well. This is the file that
routes requests to controllers and actions within them.
Bharat