# Trouble adding new view to rails project

**URL:** <https://www.ruby-forum.com/t/trouble-adding-new-view-to-rails-project/129722>\
**Category:** Rails\
**Created:** [February 21, 2008, 12:53am UTC](https://www.ruby-forum.com/t/trouble-adding-new-view-to-rails-project/129722 "2008-02-21T00:53:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![loominator1970](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/6f9a4e/32.png) [@loominator1970](https://www.ruby-forum.com/u/loominator1970)\
**Post date:** [February 21, 2008, 12:53am UTC](https://www.ruby-forum.com/t/trouble-adding-new-view-to-rails-project/129722/1 "2008-02-21T00:53:41Z")

</div>

Hey all,

I’m rather new to rails, but I do have a Rails 2.0 project up and  
running. Now I want to add a new view, let’s call it “newpage” and it  
has a link from my main page called “index.html.erb”

**\<%= link\_to ‘New Page’, :action=\> “newpage” %\>**

I assume i’ll need a file called “newpage.html.erb” in my project  
“views” folder, and i’ll need a method in my \_controller.rb  
file called “newpage”. Currently, it looks like this, but its not  
working:

def newpage

end

Anybody know what i’m missing? Do I need some other code in there?  
All I want to do at this point is display a simple page, so I assume I  
don’t need anything in the method or do I? Any help would be  
appreciated.

Dave

---

<div class="post-metadata">

**Author:** ![loominator1970](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/6f9a4e/32.png) [@loominator1970](https://www.ruby-forum.com/u/loominator1970)\
**Post date:** [February 21, 2008, 12:57am UTC](https://www.ruby-forum.com/t/trouble-adding-new-view-to-rails-project/129722/2 "2008-02-21T00:57:12Z")

</div>

> I’m rather new to rails, but I do have a Rails 2.0 project up and  
> running. Now I want to add a new view, let’s call it “newpage” and it  
> has a link from my main page called “index.html.erb”
> 
> **\<%= link\_to ‘New Page’, :action=\> “newpage” %\>**

Is your :index and :newpage in the same controller? If not you need to  
tell the link above what controller to use.

> I assume i’ll need a file called “newpage.html.erb” in my project  
> “views” folder, and i’ll need a method in my \_controller.rb  
> file called “newpage”. Currently, it looks like this, but its not  
> working:
> 
> def newpage
> 
> end

If it’s just a view you don’t even need the method declaration. Doesn’t  
hurt though.

---

<div class="post-metadata">

**Author:** ![loominator1970](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/6f9a4e/32.png) [@loominator1970](https://www.ruby-forum.com/u/loominator1970)\
**Post date:** [February 21, 2008, 1:09am UTC](https://www.ruby-forum.com/t/trouble-adding-new-view-to-rails-project/129722/3 "2008-02-21T01:09:35Z")

</div>

def newpage  
send\_data(#{RAILS\_ROOT}/app/views/index.rhtml.erb)  
end

I advice you to put your index.rhtml.erb in public folder. Hope it can  
answer your problem.

Ref:  
[http://railsmanual.org/module/ActionController::Streaming?method=send\_data](http://railsmanual.org/module/ActionController::Streaming?method=send_data)

~_~_~_~_~_~_~_~_~_~_~_~_~  
Reinhart Ariando  
YM : Booking2Heaven  
Web: [teapoci.blogspot.com](http://teapoci.blogspot.com)  
~_~_~_~_~_~_~_~_~_~_~_~_~
