"button_to" for custom action not working

First thing is I’m no using form_for or any other form tags.

I have a Model
class Modelname < ActiveRecord::Base
def self.methodfirst #Class method
:

Some code

:
end

def methodsecond #Instance method
:

Some code

:
end
end

a controller
class SomenamesController < ApplicationController

def new
@variable = Modelname.new
end

def create
Modelname.methodfirst # calling class method methodfirst
redirect_to(new_somename_path)
end

def deduction
Modelname.new.methodsecond # calling instance method
methodsecond
end

end

a partial file _form.html.erb rendered from new.html.erb

<%= button_to "create action", somenames_path, :class => "btn btn-primary" %>
<div class="actions">
  <%= button_to "deduction", action: "deduction", :class => "btn

btn-primary", method: “post” %>

new.html.erb
<%= render ‘form’ %>

Problem is: First button is working fine but not the second
<%= button_to “Start recovery printing”, recoveries_path, :class => “btn
btn-primary” %>

is working fine. Since it calls “create” action inside Somenames

But the second button is not working but throwing an error message

No route matches {:action=>“deduction”, :class=>“btn btn-primary”,
:controller=>“recoveries”, :method=>“post”}

Now how can I call custom action “deduction” written inside Somenames
controller so that it will call instance method “methodsecond”

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