小编Dra*_* C.的帖子

t.模型中迁移vs belongs_to的参考?

我正在阅读Rails指南,我找到了以下代码行:

  class CreateComments < ActiveRecord::Migration
     def change
       create_table :comments do |t|
          t.string :commenter
          t.text :body
          t.references :post

          t.timestamps
       end

       add_index :comments, :post_id
     end
 end
Run Code Online (Sandbox Code Playgroud)

我还阅读了Michael Hartl的书,Rails Tutorial,我没有找到任何关于上面代码中使用的"t.references"的内容.它有什么作用?在Michael的书中,我在模型中使用了has_many和belongs_to关系,而在迁移中没有使用任何关系(不是事件t.belongs_to).

activerecord ruby-on-rails

25
推荐指数
2
解决办法
4万
查看次数

禁用或删除apc

我在我的ubuntu 11.04 linux上安装了APC,我想制作一些性能基准测试,看看没有APC的速度提高了什么,但我不知道如何禁用/删除APC.

我试图清空我的apc.ini文件,但它没有用.我第一次加载页面后,页面将存储在缓存中,第二次加载页面时,加载速度要快得多.

这是我用来衡量时间的PHP文件.

<?php 
    function getTime() 
        { 
        $a = explode (' ',microtime()); 
        return(double) $a[0] + $a[1]; 
        } 
    $Start = getTime(); 
    ?>
    <?php require_once("includes/connection.php");?>
    <?php require_once("includes/functions.php");?>
    <?php
        find_selected_page(true);   
    ?>
    <?php require_once("includes/header.php");?>

        <table id="structure">
            <tr>
                <td id="navigation">
                    <?php echo navigation_public($sel_subject,true);
                      //            $sel_page is sent as a GLOBAL   so that we can reuse is in the page area
                    ?>
                </td>
                <td id="page">
                    <?php

                        if($sel_page!=NULL)
                        {
                            echo "<h2>".htmlentities($sel_page['menu_name'])."</h2>";
                            echo "<p>".strip_tags(nl2br($sel_page['content']),"<b><br><p><a>")."</p>";
                        }
                        else if($sel_subject!=NULL) 
                        {
                            echo "<h2>".$sel_subject['menu_name']."</h2>";
                        }
                        else 
                        {
                            echo "<h2>Welcome to …
Run Code Online (Sandbox Code Playgroud)

php apache apc ubuntu-11.04

5
推荐指数
3
解决办法
5万
查看次数

标签 统计

activerecord ×1

apache ×1

apc ×1

php ×1

ruby-on-rails ×1

ubuntu-11.04 ×1