Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm not sure whether I understand your question. (it's 3:41 AM here)</p> <p>From what I see, you directly access <code>auction_id</code> method, instead of using <code>pike_path(auction, item)</code> that'd use <code>#to_param</code>.</p> <p>Also, it might fail for <code>auction/123/item/1</code> because you haven't changed your controller.</p> <p>I think it'd be helpful to describe how to get working slugs.</p> <p>Broadly speaking, if you override <code>#to_param</code>, IDs no longer works. It means, that if you go with slugs, every time polymorpic URL is generated (eg, <code>link_to object, object</code>), it passes to_param's value. It is worth noting that you must change your controller as well.</p> <p>Personally I think that the best way to generate slugs easily is to use techno-weenie's <a href="http://github.com/technoweenie/permalink_fu/tree/master" rel="noreferrer">permalink_fu</a>, adding <code>has_permalink</code> to your model, and then, override <code>to_param</code>. For example</p> <pre><code>class Auction &lt; ActiveRecord::Base has_permalink :title, :slug end </code></pre> <p>assuming that you have slug, a string field, and want to slugize your title.</p> <p>You also need to adjust your controller:</p> <pre><code>class AuctionsController &lt; ApplicationController def show @auction = Auction.find_by_slug(params[:id]) || raise(ActiveRecord::RecordNotFound) respond_to do |format| format.html # show.html.erb end end </code></pre> <p>Then, you can generate routes, in the views, this way:</p> <pre><code>link_to @action, @action </code></pre> <p>By the way, you should NOT sort your actions in the view. The best way is to use <code>named_scope</code>.</p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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