0

This is the base structure html code.

<!DOCTYPE html>
<html>
    <head>
        <title>Layout</title>
        <link rel="stylesheet" href="style.css" />

    </head>
    <body>

        <!-- UI Object -->
        <div id="wrap">
            <p>
                #wrap
            </p>
            <!-- header -->
            <div id="header">

                <p>
                    #header
                </p>

            </div>
            <!-- //header -->
            <!-- container -->
            <div id="container">
                <p>
                    #container
                </p>
                <!-- snb -->
                <div class="snb">
                    Login
                    <input/>
                    <input/>
                    <button>
                        Login
                    </button>
                </div>
                <%=render "test/test"%>
                <!-- //snb -->
                <!-- content -->
                <!-- <div id="content">
                    <p>
                        #content
                    </p>

                </div> -->

                <!-- //content -->
            </div>
            <!-- //container -->
            <!-- footer -->
            <div id="footer">
                <p>
                    #footer
                </p>
            </div>
            <!-- //footer -->
        </div>
        <!-- //UI Object -->

    </body>
</html>

in here, the "content" part will be the dynamic part, that will be changed.

So i used <%=render "test/test"%> to render code in,

/views/test/test.html.erb

but if i run this,

it throws on error like this,

Missing partial test/test with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee]}. Searched in:

Of course, i tried to put that params like this,

<%= render :partial => 'test/test', :locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee] %>

but still have the same error.

Any good solution?

1
  • 2
    partial filenames should start with _. Commented Nov 26, 2013 at 11:06

3 Answers 3

4

Just rename your /views/test/test.html.erb file to _test.html.erb. And it will works :)

Sign up to request clarification or add additional context in comments.

2 Comments

Z Thanks for the fast response. Another quick simple question. If i program with this base structure. Every filename will be like _something.html _another.html...This looks really weird. I don't think this is the right way to code. I think i'm going the wrong way :(
Only partial name must be _name. It's rails :) Glad to help you.
1

Partial files should be named with leading '_', like _test.html.erb.

2 Comments

Thanks for the fast response. Another quick simple question. If i program with this base structure. Every filename will be like _something.html _another.html...This looks really weird. I don't think this is the right way to code. I think i'm going the wrong way :(
@Canna not "every filename", but "every partial filename" and it's completely ok.
0

The partial file names should be prefixed with underscore(_).

1 Comment

Oh, I didn't realize that the question had already been answered. Sorry for duplicating the content.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.