title: How does <%= f.submit %> know where to post?
body: <p>While messing on rails I coded this:</p>
  
  <pre><code>&lt;%= form_for :creature, url: "/creatures", method: "post" do |f| %&gt;
  
    &lt;%= f.text_field :name %&gt;
    &lt;%= f.text_area :description %&gt;
    &lt;%= f.submit "save creature" %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>I clearly understand where this posts. <strong>However</strong> I found this also works:</p>
  
  <pre><code>&lt;%= form_for @creature do |f| %&gt;
  
    &lt;%= f.text_field :name %&gt;
    &lt;%= f.text_area :description %&gt;
    &lt;%= f.submit "save creature", class: "btn btn-default"%&gt;
  
  &lt;% end %&gt;
  </code></pre>
  
  <p>I ran through the folders on my rails app, and I know that it's still posting to this endpoint <strong>post '/creatures' => 'creatures#create'</strong>. And I want to know how on earth the second block of code knows to still post to that endpoint. Moving from Node.JS to Rails is a bit mind bending. </p>
  
  <p>Here is my controller for the curious: </p>
  
  <pre><code>class CreaturesController &lt; ApplicationController
    def index
      @creatures = Creature.all
    end
  
    def new
      @creature = Creature.new
    end
  
    def create
      new_creature = params.require(:creature).permit(:name, :description)
      creature = Creature.create(new_creature)
      redirect_to "/creatures/#{creature.id}"
    end
  
    def show
      id = params[:id]
      @creature = Creature.find(id)
        end
    end
  </code></pre>