views:

20

answers:

1

Not sure why.

My model defines the object forum

  def index
    @forum = Forum.find(params[:forum_id])

But in my view it won't display the forum name. This code just comes up with "Forum : "

<h2>Forum : <%- @forum.name -%></h2>

The forum database table exists, and has an object that should be displayed!

mysql> desc forums;
+--------------+--------------+------+-----+---------+----------------+
| Field        | Type         | Null | Key | Default | Extra          |
+--------------+--------------+------+-----+---------+----------------+
| id           | int(11)      | NO   | PRI | NULL    | auto_increment |
| name         | varchar(255) | YES  |     | NULL    |                |
| description  | text         | YES  |     | NULL    |                |
| created_at   | datetime     | YES  |     | NULL    |                |
| updated_at   | datetime     | YES  |     | NULL    |                |
| topics_count | int(11)      | NO   |     | 0       |                |
+--------------+--------------+------+-----+---------+----------------+

The terminal log doesn't show any errors, so it has searched the database correctly and returned a value - it's just not showing it! Grr....

  Parameters: {"forum_id"=>"2"}
  Forum Columns (3.8ms)   SHOW FIELDS FROM `forums`
  Forum Load (0.7ms)   SELECT * FROM `forums` WHERE (`forums`.`id` = 2) 
  Topic Load (0.7ms)   SELECT * FROM `topics` ORDER BY updated_at DESC LIMIT 0, 30

Help?!?

+2  A: 

You need an =, like this:

Forum : <%= @forum.name %>

Get rid of the minuses at either end as well. That should do it!

codykrieger
Deh! Haha... man!!
mrbernz
I assume that worked, then?
codykrieger