I have a controlle/model
in for Appointment with a new action :cancel
When I create a link_to tag (tried may different ways…assigning
cancel_appointment_path(appointment) and assigning :controller =>
:appointment, :action => :cancel, id: => appointment.id ), but I’m
getting an error no matter how I try. Assuming we’re using an
appointment with id 7… I get a path /appointments/7/cancel and an error
saying action “7” not found…logs show it’s looking for action 7 and
trying to pass in id of “cancel”.
Just realized you’d asked for routes… here’s what I have (showing
just those for cancel closing…can post others if you wish).
cancel_closing POST /closing/cancel
{:controller=>“closings”, :action=>“cancel”}
formatted_cancel_closing POST /closing/cancel.:format
{:controller=>“closings”, :action=>“cancel”}
in my routes.rb I have the line for adding the method as
map.resources :closings, :member => { :cancel => :post }, :requirements
=> {:protocol => ROUTES_PROTOCOL}
Hope that helps give a bit more context.
-David
David C. wrote:
I’m having a similar issue.
I have a controlle/model
in for Appointment with a new action :cancel
When I create a link_to tag (tried may different ways…assigning
cancel_appointment_path(appointment) and assigning :controller =>
:appointment, :action => :cancel, id: => appointment.id ), but I’m
getting an error no matter how I try. Assuming we’re using an
appointment with id 7… I get a path /appointments/7/cancel and an error
saying action “7” not found…logs show it’s looking for action 7 and
trying to pass in id of “cancel”.
About your application’s environment
Ruby version 1.8.6 (i686-darwin9.5.0)
RubyGems version 1.3.1
Rails version 2.2.2
Active Record version 2.2.2
Action Pack version 2.2.2
Active Resource version 2.2.2
Action Mailer version 2.2.2
Active Support version 2.2.2
Application root /Users/dc72/Sites/aa-notary/rapps/aanotarysys
Environment development
Database adapter sqlite3
Database schema version 20090108132513
Your link_to has a cancel_appointment_path but your routes are all
cancel_closing variants. Do you have any routes in place for the
appointments_controller?
That was my mistake. Appointment object was recently split into two
objects…and the closing is the one we need to have cancelable now. I
copied my link to from an old view that’s not actually being used (my
mistake…sorry for the confusion).
So…the link I’m actually trying to get working is:
<%= link_to ‘Cancel’, cancel_closing_path(closing), :confirm => ‘Are you
sure?’ %>
So
Rick wrote:
David,
Your link_to has a cancel_appointment_path but your routes are all
cancel_closing variants. Do you have any routes in place for the
appointments_controller?