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*

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

*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"

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/1dbda2a9-229e-4cb6-987c-ddd9d16dcb04%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to