title: No route matches [GET] "/simulations"
body: <p>I am really new to this forum and to code in general :)</p>
  
  <p>I am trying to create a little simulator in my ruby on rails app. 
  I created a model that takes all the attributes to do the calculation and the final result of the simulation will be stored in an attribute of my User model.
  The objective of the simulator: the user, a freelancer, enters all his enterprise infos, and gets to know at the end of the simulation, how many taxes he has to pay. 
  I coded one of the possible path for now, in a "set_result" method for my Simulation class. </p>
  
  <p>All the attributes for the simulation are asked to the user via a simple form_for in the view and then the result of the simulation is calculated according to the user inputs to the form.
  my model looks like this :</p>
  
  <pre><code>class Simulation &lt; ApplicationRecord
    belongs_to :user
  
    ACTIVITES = ["liberale", "commerciale ou industrielle", "artisanale"]
    YEAREXISTENCE = [1, 2, 3, 4]
  
    before_save :set_result
  
    validates :activity, presence: true, inclusion: { in: ACTIVITES }
    validates :year_existence, presence: true, inclusion: { in: YEAREXISTENCE }
    validates :reglementary, presence: true
    validates :accre, presence: true
  
    def set_result
      answer = params[:simulation]
  
      if answer[:activity] == "liberale" &amp;&amp; answer[:year_existence] == 2 &amp;&amp; answer[:accre]
        self.result = 0.12
      else
        self.result = 0.23
      end
    end
  end
  </code></pre>
  
  <p>my controller :</p>
  
  <pre><code>class SimulationsController &lt; ApplicationController
    before_action :set_simulation, only: [:show, :edit, :update, :destroy, :set_tax_rate]
  
    def new
      @simulation = Simulation.new
    end
  
    def create
      binding.pry
      @simulation = Simulation.new(simulation_params)
      if @simulation.save
        render :show
      else
        render :new
      end
    end
  
    private
  
    def set_simulation
      @simulation = Simulation.find(params[:id])
    end
  
    def simulation_params
      params.require(:simulation).permit(:activity, :user_id)
    end
  end
  </code></pre>
  
  <p>and my view where I put the simple_form_for and asking all the attributes necessary to simulate the result.</p>
  
  <pre><code>&lt;div class="container"&gt;
  &lt;h1 class= "structure ml-5"&gt;simulation&lt;/h1&gt;
  &lt;/div&gt;
  
  &lt;!-- &lt;h1&gt;votre tx : &lt;%= @result %&gt;&lt;/h1&gt; --&gt;
  
  &lt;div class="row"&gt;
    &lt;div class="col-5"&gt;
      &lt;%= simple_form_for @simulation, root_path, method: :get do |f| %&gt;
  
          &lt;%= f.input :activity,
          label:"Quelle est votre catégorie d'activité ?",
          collection: Simulation::ACTIVITES,
          include_blank: true,
          as: :select %&gt;
  
          &lt;%= f.input :reglementary,
          label:"Est-ce une activité libérale règlementée ?",
          as: :boolean,
          include_blank: true,
          as: :select %&gt;
  
          &lt;%= f.input :year_existence,
          label:"Quel est l'âge de l'entreprise en année d'activité ?",
          collection: Simulation::YEAREXISTENCE,
          include_blank: true,
          as: :select %&gt;
  
          &lt;%= f.input :accre,
          label:"Avez-vous obtenu l'ACCRE lors de votre création d'entreprise ?",
          as: :boolean,
          include_blank: true,
          as: :select %&gt;
  
        &lt;%= f.submit "valider", class: "btn btn-primary" %&gt;
      &lt;% end %&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  ``````````````
  
  I tried to "binding.pry" to see if the form gets me to the create action from the controller but it seems that it does not. 
  When I get to the route : "/simulations/new", i can enter infos, but when i submit I have the error : "No route matches [GET] "/simulations"". As is I was redirecting my user to the "index" of simulations, which I don't think I did in my code...
  
  when I try to create a new simulation in my console by for example
  
  simul = Simulation.new(activity: "liberale"...)
  simul.user_id = User.last
  
  and then, trying to create it in my db :
  
  simul.save
  
  
  I get this error :
  
  "NameError: undefined local variable or method `params' for #&lt;Simulation:0x00007fcb6ea6f5b8&gt;
  from /Users/mac/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/activemodel-5.2.3/lib/active_model/attribute_methods.rb:430:in `method_missing"
  
  of course, I removed all the raise and binding.pry before trying it :)
  anyone has an idea of what gets in the way of my simulation params ???
  I am not sure of the "set_result" method and especially how I called the params for simulation... maybe that's the problem. I tried to see in my previous apps, and seems that I did the same though...
  
  </code></pre>