Note that there are some explanatory texts on larger screens.

plurals
  1. POBasic nested routing in Rails 3
    primarykey
    data
    text
    <p><em>NOTE: I have read Routing From the Inside Out AND the Engine Yard blog post on routing.</em></p> <p>I'm building a fantasy sports league, I have a League model that supports the seven basic restful operations, and they all work fine.</p> <p>I've added the following my routes.rb</p> <pre><code> resources :leagues do member do get :invite post :sendem end </code></pre> <p>Later in the file I have a resources :leagues for the basic actions</p> <p>and when I rake routes I can see:</p> <pre><code>invite_league GET /leagues/:id/invite(.:format) {:action=&gt;"invite", :controller=&gt;"leagues"} sendem_league POST /leagues/:id/sendem(.:format) {:action=&gt;"sendem", :controller=&gt;"leagues"} </code></pre> <p>which is what I would expect. I have two functions in the League controller: "invite" which creates the form for collecting email addresses, and "sendem" which invokes a mailer to actually send the invitations.</p> <p>The get for /league/:id/invite does indeed produce the form. The form tag I am using looks like:</p> <pre><code>&lt;%= form_tag(sendem_league_path, :method =&gt; "post") do %&gt; </code></pre> <p>and yet the HTML that is rendered looks like:</p> <pre><code>&lt;form accept-charset="UTF-8" action="/leagues/1" class="edit_league" id="edit_league_1" method="post"&gt; </code></pre> <p>And hence on submit generates a PUT which is completely wrong. (It should post to the sendem function.) My change to the routes file appears <em>above</em> the generic resources :leagues line, so it <em>should</em> have a higher priority.</p> <p>I'm sure there is something dead-simple that I missed but I'm out of ideas. (And hair).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload