# \[newbie question\]how to add a new view to a exist controller?

**URL:** <https://www.ruby-forum.com/t/newbie-question-how-to-add-a-new-view-to-a-exist-controller/194471>\
**Category:** Rails\
**Created:** [September 6, 2010, 4:39pm UTC](https://www.ruby-forum.com/t/newbie-question-how-to-add-a-new-view-to-a-exist-controller/194471 "2010-09-06T16:39:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![john-anes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/22d042/32.png) [@john-anes](https://www.ruby-forum.com/u/john-anes)\
**Post date:** [September 6, 2010, 4:39pm UTC](https://www.ruby-forum.com/t/newbie-question-how-to-add-a-new-view-to-a-exist-controller/194471/1 "2010-09-06T16:39:38Z")

</div>

hello everybody , I am a newbie to Rails’ world.  
I just start reading the book   
one question.  
How can I add a new view to a exist controller?

we can use  
code:  
rails generate controller controller\_1\_name [view\_1\_name  
view\_2\_name]

however. if I wanna add a view\_3 to controller\_1, how can I do with a  
single line command?

I have tried two ways  
First:  
rails generate controller controller\_1\_name view\_3\_name  
conflict  
Second  
rails generate controller controller\_1\_name [view\_1\_name  
view\_2\_name view\_3\_name]  
still conflict

Does anyone have a solution?

---

<div class="post-metadata">

**Author:** ![john-anes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/22d042/32.png) [@john-anes](https://www.ruby-forum.com/u/john-anes)\
**Post date:** [September 6, 2010, 4:39pm UTC](https://www.ruby-forum.com/t/newbie-question-how-to-add-a-new-view-to-a-exist-controller/194471/2 "2010-09-06T16:39:45Z")

</div>

On Sep 4, 5:16 am, John A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> hello everybody , I am a newbie to Rails’ world.  
> I just start reading the book   
> one question.  
> How can I add a new view to a exist controller?
> 
> we can use  
> code:  
> rails generate controller controller\_1\_name [view\_1\_name  
> view\_2\_name]
> 
> however. if I wanna add a view\_3 to controller\_1, how can I do with a  
> single line command?

could you not just create app/views/controller\_1/view\_3.html.erb?

Fred

---

<div class="post-metadata">

**Author:** ![john-anes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/22d042/32.png) [@john-anes](https://www.ruby-forum.com/u/john-anes)\
**Post date:** [September 6, 2010, 4:39pm UTC](https://www.ruby-forum.com/t/newbie-question-how-to-add-a-new-view-to-a-exist-controller/194471/3 "2010-09-06T16:39:49Z")

</div>

Thank you for replying.  
Yes. I can just create a view\_3.html.erb and add a new definition for  
view\_3 as  
def view\_3  
# some code  
end

Is there no way to create all of them just by enter single line  
command ? Maybe in Rails 4 😃 ?

On Sep 4, 5:31 pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
