Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

polymorphic_url should treat an array contains single name as without the container

#1386

After I posted #1317 polymorphic_url should compact given array, I realized I missed one more feature I want to be patched.

You may see what I want by an excerpt from my new patch.


  def test_with_array_containing_single_name
  @article.save
  expects(:articles_url)
  polymorphic_url([:articles])
end

That it.

Reported by hiroshi · November 16th, 2008 @ 09:20 AM

State: committed
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. DHH
    DHH

    I'm not sure I quite understand what this does? What was the behavior before this?

    November 16th, 2008 @ 08:44 PM

  2. hiroshi
    hiroshi

    Before this change, the test I added failed.

    
      1) Error:
    test_with_array_containing_single_name(PolymorphicRoutesTest):
    NoMethodError: undefined method `articles_nil_class_url' for #<PolymorphicRoutesTest:0x1045528>
    

    However, giving an array consists of an object doesn't raise NoMethodError nor any.

    
    def test_with_array_containing_single_object
      @article.save
      expects(:article_url).with(@article)
      polymorphic_url([nil, @article]) # argument will be [@article] with former patch #1317
    end
    

    I wish this explain my intention.

    November 17th, 2008 @ 02:08 AM

  3. Repository
    Repository
    • State changed from new to committed

    (from [591560c641d52f6a8fb12a26c60c3f812735ac0d]) Let polymorphic_path treat an array contains single name as without array [#1386 polymorphic_url should treat an array contains single name as without the con... state:committed]

    Signed-off-by: David Heinemeier Hansson david@loudthinking.com http://github.com/rails/rails/co...

    November 19th, 2008 @ 11:07 AM

  4. Repository
    Repository

    (from [291d199de1271c254c44b94766d13013b222a125]) Let polymorphic_path treat an array contains single name as without array [#1386 polymorphic_url should treat an array contains single name as without the con... state:committed]

    Signed-off-by: David Heinemeier Hansson david@loudthinking.com http://github.com/rails/rails/co...

    November 19th, 2008 @ 11:07 AM