2013-04-01 38 views
3

裏面我把這個我ERB文件紅寶石HTML-ERB文件問題

<% @user_friend.each do |friends| -%> 
    <%= content_tag :p, :class => "popin" do %> 
    friends.email 
    <% end %> 
<% end -%> 

內,我收到此錯誤信息:

compile error 
/var/www/gitorious/app/views/campaigns/new.html.erb:25: syntax error, unexpected ')' 
..._tag :p, :class =>"popin" do).to_s); @output_buffer.concat ... 
          ^
/var/www/gitorious/app/views/campaigns/new.html.erb:28: syntax error, unexpected kEND, expecting ')' 
; end ... 

有人能解釋我是如何解決這個問題?

+0

哪個軌道的版本您使用的? Rails 2不需要內容標籤上的<%= on,而rails 3則可以。如果您使用的是導軌2,請使用<%content_tag .... do%> –

回答

4

friends.email是Ruby代碼,您需要做的僅僅象下面這樣:

<% @user_friend.each do |friends| -%> 
    <%= content_tag :p, friends.email,:class =>"popin" %> 
<% end -%> 
+0

謝謝,但我知道您的答案。我只是想弄清楚如何在'content_tag ... do'技巧中添加一些更復雜的ruby代碼? – user1611830

+0

@ user1611830當然你也可以把你的ruby代碼包裝在'<%= ... %>'裏面。 – xdazz

+0

你仍然需要放置friends.email <%= %>,所有的ruby代碼需要包裝在正確的標籤 – Egryan