在这种情况下如何正确建立链接?

时间:2021-02-22 22:50:38

I'm trying to make the link to Amazon associate's.

我正在尝试链接到亚马逊的员工。

If I put keyword between <a type=amzn> and </a> it automatically makes link to the amazon search result page with keyword.

如果我在之间添加关键字,它会自动使用关键字链接到亚马逊搜索结果页面。

I'm trying to make the button that works that way.
How can I archive that?

我正在尝试按下那样工作的按钮。我该如何存档?

It should be something like this.

它应该是这样的。

view

<%= link_to "Buy", "<a type=amzn >" + @book.title + "</a>", :class => 'btn' %>

2 个解决方案

#1


2  

Try something like:

尝试以下方法:

<%= link_to @book.title, "", :class => 'btn btn-primary', :type => 'amzn' %>

#2


1  

How about something like this:

这样的事情怎么样:

<%= link_to @book.title, :class => "btn" do %>
  and
<% end %>

Where and is whatever you want the text on the link to be.

无论你想要什么,你想要链接上的文字。

I am not 100% sure if I am understanding what you are looking for, correctly - but if I am...then this should work.

如果我理解你正在寻找的东西,我并不是100%肯定 - 但如果我......那么这应该有效。

#1


2  

Try something like:

尝试以下方法:

<%= link_to @book.title, "", :class => 'btn btn-primary', :type => 'amzn' %>

#2


1  

How about something like this:

这样的事情怎么样:

<%= link_to @book.title, :class => "btn" do %>
  and
<% end %>

Where and is whatever you want the text on the link to be.

无论你想要什么,你想要链接上的文字。

I am not 100% sure if I am understanding what you are looking for, correctly - but if I am...then this should work.

如果我理解你正在寻找的东西,我并不是100%肯定 - 但如果我......那么这应该有效。