时间:2011-01-06 16:23:20

标签: ruby-on-rails imagemap

3 个答案:

答案 0 :(得分:8)

答案 1 :(得分:2)

只需使用url_for生成所需的网址

<img usemap="image_link" src="..." alt="" width="235" height="32" style="display: block;" />
<map name="image_link">
    <area href="<%= url_for root_path %>" alt="Home" coords="0,0,189,19" shape="rect" />
    <area href="<%= url_for :controller => "post", :action => "all" %>" alt="All posts" coords="190,0,386,22" shape="rect" />
    <area href="<%= url_for new_resource1_path %>" alt="New resource1" coords="387,0,657,23" shape="rect" />
</map>

root_path被定义为主页,resource1被定义为config / routes.rb中的资源。

答案 2 :(得分:0)