Yu-Chieh’s Blog (Y.C. Chang)

Ruby on Rails / Rubygems / FullStack / Git / Mac notes.

Some Link_to Usage Tips

some tips for link_to helper

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#in view/xxxx.html.erb

<%= link_to "LINK_NAME", xxx_path %>

<%= link_to "LINK_NAME", "LINK_URL", id: "ID_NAME", class: "CLASS_NAME" %>


# use it like a block
# 1
link_to "LINK_URL" do
  image_tag "IMAGE_FILE"
end

# 2
link_to xxx_path do
  image_tag "IMAGE_FILE"
end

Comments