Text Field Value unless?

Hello,

Why is this not working :frowning:

<%= text_field_tag :post_header, ‘’, :name => ‘post[header]’, :value
@post.header if @post.header %>

I want the default value to be @post.header if it’s not nil :slight_smile:

Thanks :smiley:

You can’t have an if statement embedded in a method like this. Not to
mention you are missing the => operator. Try this:

<%= text_field_tag :post_header, ‘’, :name => ‘post[header]’, :value
=> @post.header ? @post.header : ‘’ %>

On May 5, 8:37 am, Jamal S. [email protected]

dasil003 wrote:

You can’t have an if statement embedded in a method like this. Not to
mention you are missing the => operator. Try this:

<%= text_field_tag :post_header, ‘’, :name => ‘post[header]’, :value
=> @post.header ? @post.header : ‘’ %>

On May 5, 8:37 am, Jamal S. [email protected]

Thanks,

It rocks :smiley: