# Rials varable becomes nill on a render

**URL:** <https://www.ruby-forum.com/t/rials-varable-becomes-nill-on-a-render/85700>\
**Category:** Ruby\
**Created:** [February 15, 2007, 5:22pm UTC](https://www.ruby-forum.com/t/rials-varable-becomes-nill-on-a-render/85700 "2007-02-15T17:22:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dgm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/df788c/32.png) [@dgm](https://www.ruby-forum.com/u/dgm)\
**Post date:** [February 15, 2007, 5:22pm UTC](https://www.ruby-forum.com/t/rials-varable-becomes-nill-on-a-render/85700/1 "2007-02-15T17:22:35Z")

</div>

First off apologies for a rails question on the ruby list, but the  
rails mailing list sign-on page seems to be down at the moment so I  
thought I would look for help here.

Bearing in mind I am very new to Rails… I have a create action:

def create  
@post = Post.new(params[:post])  
if @post.save  
@post.tag\_with(params[:tag\_list])  
flash[:notice] = ‘Post was successfully created.’  
redirect\_to :action =\> ‘list’  
else  
@tag\_list = params[:tag\_list]  
render :action =\> ‘new’  
end  
end

if the @post.save returns false the user is presented with the new  
view again:

def new  
@tags = Tag.find(:all)  
@post = Post.new  
end

On the initial call to new the new view displays a list of tags from  
the array @tags. If the create action fails and the render :action =\>  
‘new’ line is executed the @tags variable becomes nill

How come this happens? and is there a ‘clean’ was of keeping the  
@tags variable as it should be no matter how many times the create  
action fails??

Any help will be gratefully received.

David.
