开发者

Rails 3 - What's wrong with this CASE Statement?

开发者 https://www.devze.com 2023-01-18 17:03 出处:网络
<% @feed.each do |feed| %> <ul id=\"feed\"> <%= case feed.action_type when \"COMM开发者_如何学GoENT\"
<% @feed.each do |feed| %>

    <ul id="feed">

        <%= 
            case feed.action_type
            when "COMM开发者_如何学GoENT"
                <%= render :partial => "feeds/storyitem" -%>,
            end
        %>
    </ul>
<% end %>


You can't nest ERB tags like that -- you're trying to insert the render... ERB tag when you're already inside ERB. If that's what you really want to do, try this:

<% @feed.each do |feed| %>

    <ul id="feed">
        <% case feed.action_type
        when "COMMENT" %>
            <%= render :partial => "feeds/storyitem" -%>,
        <% end %>
    </ul>
<% end %>

But unless you've simplified the code example for posting it here, the <% if %> looks clearer to me.


ok figured it out:

<% @feed.each do |feed| %>

    <ul id="feed">

        <%= 
            case feed.action_type
            when "COMMENT"
                render :partial => "feeds/storyitem"
            end
        %>
    </ul>
<% end %>

no need for the <% around the render partial

0

精彩评论

暂无评论...
验证码 换一张
取 消