:method => :delete not working

Dear All,
i want to delect a record with the code
<% @reservations.each do |reservation| %>

00000<%= reservation.id%> <%= reservation.item_desc %> <%= reservation.item_desc %> <%= reservation.created_on %> <%= reservation.valid_until %> <%= link_to 'Destroy',reservation, :confirm => 'Are you sure?' ,:method => :delete%>

but when i click the link ,it will redirect to the show page ,it means
that the show action is invoked,acturally i want to delete it not show
the details, so ,i think the :method=>:delete doesnt work, i search a
lot to find the solution,some advise to add <%= javascript_include_tag
:all %> to the layout,but it still doesnt work, anyone can help me ?
Thanks very much.

PS:


these two links provide the solution about this kind of problem,i tried,
but it doesnt work.

Hi, could you post your controller code too?

On Thu, Jan 26, 2012 at 3:19 AM, Daisy Di [email protected] wrote:

        sure?' ,:method => :delete%></td>

but when i click the link ,it will redirect to the show page ,it means
that the show action is invoked,acturally i want to delete it not show
the details, so ,i think the :method=>:delete doesnt work, i search a
lot to find the solution,some advise to add <%= javascript_include_tag
:all %> to the layout,but it still doesnt work, anyone can help me ?
Thanks very much.

you want to destroy them using ajax? or just destroy?
What do you have on your destroy action in the controller?

Javier

On Thu, Jan 26, 2012 at 10:38 PM, Daisy Di [email protected] wrote:

redirect_to redeemhistory_path
end

Why do you comment the line that destroy the reservation?.. or your
idea
of destroy it is by changing its status?

Javier

Andre wrote in post #1042629:

Hi, could you post your controller code too?

Hi, this is the destroy controller, i wont delete the record,just change
the status to -1.

def destroy
@reservation = CrmRedemptionReservation.find(params[:id])
@reservation.update_attributes(:status_level => -1)
#@reservation.destroy
redirect_to redeemhistory_path
end

What this probably means is that the javascript that handles your
delete links is not being loaded.

What version of Rails is this? I hit this issue a couple times with
early iterations of Rails 3 before the asset pipeline kicked in.

  • Brian Haberer

On 26 January 2012 08:19, Daisy Di [email protected] wrote:

  sure?' ,:method => :delete%></td>

but when i click the link ,it will redirect to the show page ,it means
that the show action is invoked,acturally i want to delete it not show
the details, so ,i think the :method=>:delete doesnt work, i search a
lot to find the solution,some advise to add <%= javascript_include_tag
:all %> to the layout,but it still doesnt work, anyone can help me ?

Have you checked in log/development.log to see what is logged when you
click the link?

Colin

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