Is the equality failing or is something else going on?

I’m trying to prototype, but I’m running into an error after modifying
the scaffolding slightly.

    if(column.name == 'content')
        page.send(column.name)
    else
        render_template 'rhtml', page.send(column.name)
    end

I have a datetime field and I’m getting this error “can’t convert Time
into String” and the render_template line is causing the problem. The
‘content’ column isn’t a datetime field. So the if statement is
failing.

Another question, I’m trying to pretty this up using an ‘unless’
statement but I can’t seem to figure it out

<%= page.send unless column.name ==‘content’ render_template ‘rhtml’,
page.send(column.name) %> doesn’t seem to work either. Rails spits out
a problem with a missing ‘)’ after ‘render_template’. Any ideas?

On Dec 31, 2006, at 4:03 PM, pureflight1080 wrote:

I have a datetime field and I’m getting this error “can’t convert Time
into String” and the render_template line is causing the problem. The
‘content’ column isn’t a datetime field. So the if statement is
failing.

It looks like you’re using the old-style render_template… not sure
if that’s causing difficulty or not. Try this:

render :template => “path/to/template”

You could try this too, although I’m not certain I’m thinking the
same thing you’re thinking:

render :template => “path/to/#{column.name}”, :locals => {:value =>
page.send(column.name)}

Then, in each of your #{column.name}.rhtml files, you will have a
local variable called ‘value’ which contains the value of the
relevant column.

Another question, I’m trying to pretty this up using an ‘unless’
statement but I can’t seem to figure it out

<%= page.send unless column.name ==‘content’ render_template ‘rhtml’,
page.send(column.name) %> doesn’t seem to work either. Rails spits
out
a problem with a missing ‘)’ after ‘render_template’. Any ideas?

It looks like you’re trying to do an unless / else statement on one
line, so you’ll need a ‘then’ and an ‘else’. You’ll also need to
clean up the code a little, as it seems you’re not actually 'send’ing
anything to ‘page’… actually, I’m not sure about that, but the Ruby
syntax isn’t right anyway, so maybe that’s why the parser in my head
won’t work :slight_smile:

<%= unless column.name ==‘content’ then render_template(‘rhtml’,
page.send(column.name)) else page.send(column.name) end %>

Duane J.
(canadaduane)
http://blog.inquirylabs.com/