Call method without opening show view - Rails -


i have method run controller, should done clicking button, issue have when click on specific line or item redirect item's view.

here route have created: patch '/withdraw/:id', to: 'payments#withdraw', as: :withdraw

this link_to line: <%= link_to 'withdraw', withdraw_path(pay), method: :post %>

and method, updating existing attributes:

def withdraw  @payment = payment.find(params[:id])  @payment.withdrawn = true  @payment.amount_interest = @payment.amount * 1.1  @payment.save end 

what need change in order desired result? assistance appreciated.

add remote: true link.

<%= link_to 'withdraw', withdraw_path(pay), method: :patch, remote: true %> 

and add head :ok @ end of action:

def withdraw   ..   head :ok end 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -