First thing is I’m no using form_for or any other form tags.
I have a controller
class SomenamesController < ApplicationController
def new
@variable = Modelname.new
end
def create
Modelname.methodfirst # methodfirst is class
method
redirect_to(new_somename_path)
end
def deduction
Modelname.new.methodsecond # calling instance method of
Modelname
end
end
a Model
class Modelname < ActiveRecord::Base
def self.methodfirst
:
Some code
:
end
def methodsecond
:
Some code
:
end
end
a partial file _form.html.erb rendered from new.html.erb
new.html.erb
<%= render ‘form’ %>
Problem is:
<%= 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”