Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Missing Partial Error in Rails 3

I am getting an error:

Missing partial post/questions, application/questions with
{:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee]}.
Searched in:* "/Users/..../<project name>/app/views"

I tried to render all posts in the database to index.html.erb.

My view part is post/index.html.erb:

    <!--html codes -->

    <%= render 'questions' %>

Controller controller/post_controller.rb:

    def index
       @posts=Post.all
    end

    def questions
    end

questions.html.erb

    <%[email protected] do |post| %>
    <table>
        <tr>
            <td>
                <h2>
                    <%=post.title%>
                </h2>
            </td>
        </tr>
        <tr>
            <td>
                <h3><%=post.body%></h3>
            </td>
        </tr>
        <tr>
            <td>
                This Post comes under:<h4><%=post.tag%></h4>
            </td>
        </tr>
    </table>
like image 379
Cyber Avatar asked Jun 08 '12 05:06

Cyber


1 Answers

Partials' file names must begin with an underscore. You should have _questions.html.erb saved in the post folder. Also, you don't need to define a 'questions' action.

like image 108
cdesrosiers Avatar answered Oct 04 '22 21:10

cdesrosiers