开发者

id parameter on link_to

My question it's very simple, but I don't find a solution.

I'm using:

  • Rails 3.0.9
  • ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]

The question it's:

In older rails version when create a link using link_to function, like this:

link_to owner.name,
    {
        :controller => 'owner',
        :action => 'view',
        :id开发者_开发技巧 => owner
    },
    :title => owner.name

Returns:

<a href="/owner/view/10001" title="Bla, bla, bla, bla">I'm using rails</a>

But now (in rails 3) it's returning:

<a href="/owner/view?id=10001" title="Bla, bla, bla, bla">I'm using rails</a>

Thanks in advance.

P.S: I'm a newbie english spoken.


You can specify you root in routes.rb:

match '/owner/view/:id' => 'owner#view', :as => :owner_view

and then use it like this:

link_to owner.name, owner_view_path(owner)


try this

link_to owner.name, owner, :title => owner.name

If your action is detail, then:

link_to owner.name, [:detail, owner], :title => owner.name

And be sure that your detail action is included in your routes

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜