# Weired render action question! help!

**URL:** <https://www.ruby-forum.com/t/weired-render-action-question-help/90943>\
**Category:** Deployment\
**Created:** [April 3, 2007, 5:56am UTC](https://www.ruby-forum.com/t/weired-render-action-question-help/90943 "2007-04-03T05:56:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![grandtang](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/5e9695/32.png) [@grandtang](https://www.ruby-forum.com/u/grandtang)\
**Post date:** [April 3, 2007, 5:56am UTC](https://www.ruby-forum.com/t/weired-render-action-question-help/90943/1 "2007-04-03T05:56:13Z")

</div>

Weired render action question! help!  
In a topic controller

def edit  
@topic = Topic.find(params[:id])  
end  
def update  
@topic = Topic.find(params[:id])  
@topic.subject = params[:topic][:subject]  
@topic.body = params[:topic][:body]  
@topic.modificationDate = Time.now  
if @topic.update\_attributes(params[:topic])  
flash[:notice] = ‘Topic was successfully updated.’  
redirect\_to :action =\> ‘show’, :id =\> @topic.root\_id  
else  
flash[:notice] = ‘Failed to update the Topic.’  
render :action =\> ‘edit’  
end  
end

edit.rhtml forum action --\> update, if user input error, such as subject  
is null,then will render back edit.rhtml, and display the error message!  
it works!

def newTopic  
@topic = Topic.new  
end  
def createTopic  
@topic = Topic.new(params[‘topic’])  
@topic.creationDate = Time.now  
@topic.modificationDate = Time.now  
if @topic.save  
flash[:notice] = ‘Topic was successfully created.’  
redirect\_to :action =\> ‘index’  
else  
flash[:notice] = ‘Failed to create a Topic’  
render :action =\> ‘newTopic’  
end  
end

if you want to post a new root topic, if subject is null, then render  
back to newTopic.rhtml, display error message!

but…

def reply  
@parent = Topic.find(params[:id])  
end  
def replyTopic  
parent = Topic.find(params[:parentID])  
@topic = Topic.new(params[‘topic’])  
if parent.root?  
root\_id = params[:parentID]  
else  
root\_id = parent.root\_id  
end  
@topic.root\_id = root\_id  
@topic.creationDate = Time.now  
@topic.modificationDate = Time.now  
if @topic.save  
flash[:notice] = ‘Topic was successfully created.’  
parent.add\_child(@topic)  
redirect\_to :action =\> ‘show’, :id =\> root\_id  
else  
flash[:notice] = ‘Oops, there was a problem!’  
# redirect\_to :action =\> ‘new’, :id =\> params[:parentID]  
render :action =\> ‘reply’  
end  
end

if you reply a topic, reply.rhtml will display parent topic information,  
then forum action to replyTopic, if user input error, it could’nt render  
back to reply.rhtml, display @parent nil object error!why?

---

<div class="post-metadata">

**Author:** ![grandtang](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/5e9695/32.png) [@grandtang](https://www.ruby-forum.com/u/grandtang)\
**Post date:** [April 3, 2007, 6:01am UTC](https://www.ruby-forum.com/t/weired-render-action-question-help/90943/2 "2007-04-03T06:01:58Z")

</div>

newTopic --\> createTopic, render works!  
input parameter: id --\> edit --\> update, render works!  
input parameter: id --\> reply --\> replyTopic, render dosen’t works!

why???

---

<div class="post-metadata">

**Author:** ![grandtang](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/5e9695/32.png) [@grandtang](https://www.ruby-forum.com/u/grandtang)\
**Post date:** [April 3, 2007, 6:20am UTC](https://www.ruby-forum.com/t/weired-render-action-question-help/90943/3 "2007-04-03T06:20:18Z")

</div>

On 03/04/2007, at 2:01 PM, Chengcai He wrote:

> newTopic → createTopic, render works!  
> input parameter: id → edit → update, render works!  
> input parameter: id → reply → replyTopic, render dosen’t works!
> 
> why???

Only deployment related issues here please. Rails support questions  
should be directed at:  
[http://www.railsweenie.com/](http://www.railsweenie.com/)

> **[Community](https://rubyonrails.org/community)**
>
> A web-app framework that includes everything needed to create database-backed web applications according to the Model-View-Controller (MVC) pattern.

– tim
