想输出如下html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
<% if
user.present? %> <li> <a href= "<%= user_info_url(user.id) %>" ><%= user.nickname %> <br><%= image_tag user.head_img_url %></a> </li> <% else
%> <li> <a href= "#" >空<br><%= image_tag
'blank.jpg' %></a> <p></p> <p><button
class = "btn btn-normal" >点亮</button></p> </li> <% end
%> |
可以在helper中定义一个方法,内容如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
content_tag
:li do if
user.present? html = link_to user_info_url(user.id)
do concat user.nickname concat tag( :br ) concat image_tag(user.head_img_url) end concat html concat content_tag
:div , '' ,
class : 'mask' else link_to
'#' do concat
'空' concat tag( :br ) concat image_tag( 'blank.jpg' ) end end end |
已经验证过在项目中的顶部返回导航!