2012-02-16 35 views
0

我一直在关注Jobeet教程。我是第7天我都相应复制的文件,但是接收404错误:Action“default/show”不存在Symfony 1.4 Jobeet Day 7

Action "default/show" does not exist 

模块/类别/动作/的actions.class.php

class categoryActions extends sfActions 
{ 
    public function executeShow(sfWebRequest $request) 
    { 
     $this->category = $this->getRoute()->getObject(); 
     $this->pager = new sfDoctrinePager('JobeetJob', sfConfig::get('app_max_jobs_on_category')); 
     $this->pager->setQuery($this->category->getActiveJobsQuery()); 
     $this->pager->setPage($request->getParameter('page', 1)); 
     $this->pager->init(); 
    } 
} 

模块/类别/templates/showSuccess.php

<?php use_stylesheet('jobs.css') ?> 

<?php slot('title', sprintf('Jobs in the %s category', $category->getName())) ?> 

<div class="category"> 
    <div class="feed"><a href="">Feed</a></div> 
    <h1><?php echo $category ?></h1> 
</div> 

<?php include_partial('job/list', array('jobs' => $category->getActiveJobs())) ?> 


<?php if ($pager->haveToPaginate()): ?> 
    <div class="pagination"> 
    <a href="<?php echo url_for('category', $category) ?>?page=1"> 
     <img src="http://www.symfony-project.org/images/first.png" alt="First page" title="First page" /> 
    </a> 

    <a href="<?php echo url_for('category', $category) ?>?page=<?php echo $pager->getPreviousPage() ?>"> 
     <img src="http://www.symfony-project.org/images/previous.png" alt="Previous page" title="Previous page" /> 
    </a> 

    <?php foreach ($pager->getLinks() as $page): ?> 
     <?php if ($page == $pager->getPage()): ?> 
      <?php echo $page ?> 
      <?php else: ?> 
      <a href="<?php echo url_for('category', $category) ?>?page=<?php echo $page ?>"><?php echo $page ?></a> 
     <?php endif; ?> 
    <?php endforeach; ?> 
    <a href="<?php echo url_for('category', $category) ?>?page=<?php echo $pager->getNextPage() ?>"> 
     <img src="http://www.symfony-project.org/images/next.png" alt="Next page" title="Next page" /> 
    </a> 
    <a href="<?php echo url_for('category', $category) ?>?page=<?php echo $pager->getLastPage() ?>"> 
     <img src="http://www.symfony-project.org/images/last.png" alt="Last page" title="Last page" /> 
    </a> 
    </div> 
<?php endif; ?> 

<div class="pagination_desc"> 
    <strong> 
    <?php echo count($pager) ?> 
    </strong> 
    jobs in this category <?php if ($pager->haveToPaginate()): ?> - page <strong><?php echo $pager->getPage() ?>/<?php echo $pager->getLastPage() ?> 
    </strong> 
<?php endif; ?> 
</div> 

前端/配置/ routing.yml中

category: 
url: /category/:slug 
class: sfDoctrineRoute 
param: { model: category, action: show } 
options: { model: JobeetCategory, type: object } 

job: 
class: sfDoctrineRouteCollection 
options: { model: JobeetJob } 

job_show_user: 
url: /job/:company_slug/:location_slug/:id/:position_slug 
class: sfDoctrineRoute 
options: 
    model: JobeetJob 
    type: object 
    method_for_query: retrieveActiveJob 
param: { module: job, action: show } 
requirements: 
    id: \d+ 
    sf_method: [get] 

# default rules 

homepage: 
url: /
param: { module: job, action: index } 

#default_index: 
# url: /:module 
# param: { action: index } 
# 
#default: 
# url: /:module/:action/* 

我按照手册说明删除了indexSuccess.php。不知道这是否是问题。任何帮助将是伟大的!

回答

0

想通了。这是一个简单的错字错误。我必须使用Beyond Compare才能看到它。

category: 
url: /category/:slug 
class: sfDoctrineRoute 
param: { model: category, action: show } 
options: { model: JobeetCategory, type: object } 

应该是:

category: 
url: /category/:slug 
class: sfDoctrineRoute 
param: { module: category, action: show } 
options: { model: JobeetCategory, type: object } 

模型和模块之间很大的区别。