2016年2月1日月曜日

rails4.2.x Combine div tag with link_to

  • Published Date:Feb. 1, 2016

Article Summary

Explain how to combine div tag with link_to.

日本語で読む

Environment

  • rails4.2.4
  • ruby2.3.0

link_to

When you create web app on Rails, there are opportunities to combine div tag with a tag.
For example, HTML source, as follows:

{app_folder}/app/view/xxx.erb

<a href="">
<div>
 // image or text
</div>
</a>

A HTML described above could be combined div tag with like_to tag, as follows:

{app_folder}/app/view/xxx.erb

<%= link_to test_path(@test) do %>
<div>
 // image or text
</div>
<% end %>

link_to tag block surrounds div tag, Creates a link tag of div.

Conclusion

Blocks are one of the most useful function of ruby.
if you have a little time, I recommend that you study block of ruby.

See you.

日本語

0 件のコメント:

コメントを投稿