Newbie problem – getting 404 on test model

edited November 2014 in Bug Reports
So I basically recreated the articles model, and I can update the database and view all of the "races" I create, but I cannot go to an individual race. Any thoughts why?

Here's my races model:

<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); require_once(FUEL_PATH.'models/base_module_model.php'); class Races_model extends Base_module_model { public $required = array('title'); public $unique_fields = array('slug'); public $has_many = array('tags' => array(FUEL_FOLDER => 'fuel_tags_model')); function __construct() { parent::__construct('races'); } function list_items($limit = NULL, $offset = NULL, $col = 'title', $order = 'asc', $just_count = FALSE) { $this->db->select('races.id, title, date_added, races.published', FALSE); $data = parent::list_items($limit, $offset, $col, $order, $just_count); // check just_count is FALSE or else $data may not be a valid array if (empty($just_count)) { foreach($data as $key => $val) { $data[$key]['title'] = htmlentities($val['title'], ENT_QUOTES, 'UTF-8'); } } return $data; } } class Race_model extends Data_record { public function get_url() { return site_url('races/'.$this->slug); } public function get_image_path() { return img_path('images/'.$this->image); } public function get_thumb_image_path() { return img_path('images/'.$this->thumb_image); } }



Here's my races view:

<?php $slug = uri_segment(2); var_dump($slug); if ($slug) : $race = fuel_model('races', array('find' => 'one', 'where' => array('slug' => $slug))); if (empty($race)) : redirect_404(); endif; else: $tags = fuel_model('tags'); endif; if (!empty($race)) : ?> <h1><?=fuel_edit($race)?><?=$race->title?></h1> <div class="author"><?=$race->location?></div> <img src="<?=$race->image_path?>" alt="<?=$race->title_entities?>" class="img_right" /> <article><?=$race->site_url?></article> <?php else: ?> <h1>Races</h1> <?=fuel_edit('create', 'Create Race', 'races')?> <?php foreach($tags as $tag) : ?> <ul> <?php foreach($tag->races as $race) : ?> <li><?=fuel_edit($race)?><a href="<?=$race->url?>"><?=$race->title?></a></li> <?php endforeach; ?> </ul> <?php endforeach; ?> <?php endif; ?>

Comments

Sign In or Register to comment.