# Newbie question about views folder

**URL:** <https://www.ruby-forum.com/t/newbie-question-about-views-folder/189024>\
**Category:** Rails\
**Created:** [May 22, 2010, 4:42am UTC](https://www.ruby-forum.com/t/newbie-question-about-views-folder/189024 "2010-05-22T04:42:00Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![FrankMurphy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e99b99/32.png) [@FrankMurphy](https://www.ruby-forum.com/u/FrankMurphy)\
**Post date:** [May 22, 2010, 4:42am UTC](https://www.ruby-forum.com/t/newbie-question-about-views-folder/189024/1 "2010-05-22T04:42:00Z")

</div>

Hi,

I just started out learning Ruby on Rails this week. I’m using Michael  
Hartl’s book, but I’m working on a remote server rather than my local  
computer. As such, I’m using Apache + Passenger to deploy the example  
programs rather than Mongrel. Also, I’m using MySQL for my database  
instead of SQLite.

My issue is that I don’t understand how to deploy a program on a  
remote server using Apache + Passenger in a way that makes the  
contents of the views directory accessible. For instance, if I create  
a sample program ‘demo\_app’ and create a ‘users’ resource with the  
command:

$ script/generate scaffold User name:string email:string

and then migrate with the command:

$ rake db:migrate

I can’t see the ‘users’ folder or anything in it when I point my  
browser to the remote server. I can see the standard ‘Welcome aboard!’  
page at http://\<server\_addr\>/demo\_app, but  
http://\<server\_addr\>/demo\_app/users  
gives me a 404 Not Found. In my apache2.conf file, I have the  
following VirtualHost specification:

\<VirtualHost \*:80\>  
ServerName \<server\_addr\>  
DocumentRoot /projects/demo\_app/public  
RailsBaseURI /demo\_app

In my web root directory, ‘demo\_app’ is a symbolic link to the  
application’s public directory. I realize that there’s nothing in my  
web root directory or the above VirtualHost specification that points  
to the ‘users’ resource, but when I build this app locally and view it  
with Mongrel, I can see [http://0.0.0.0:3000/users](http://0.0.0.0:3000/users) just fine. All of  
the documentation I’ve read indicates that the above specification and  
symbolic link are all I need to create to deploy an app on a remote  
server with Apache + Passenger. Do I need to do something else to  
access http://\<server\_addr\>/demo\_app/users? Have I missed an obvious  
or elementary step? Am I misunderstanding something? Am I on another  
planet?

Any help would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![FrankMurphy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e99b99/32.png) [@FrankMurphy](https://www.ruby-forum.com/u/FrankMurphy)\
**Post date:** [May 22, 2010, 4:47am UTC](https://www.ruby-forum.com/t/newbie-question-about-views-folder/189024/2 "2010-05-22T04:47:16Z")

</div>

Hi Frank,

On Fri, May 21, 2010 at 8:45 PM, FrankMurphy  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> I can see the standard ‘Welcome aboard!’  
> page at http://\<server\_addr\>/demo\_app,

Just a swag here, but did you delete public/index.html on the remote  
server?

Best regards,  
Bill

---

<div class="post-metadata">

**Author:** ![FrankMurphy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e99b99/32.png) [@FrankMurphy](https://www.ruby-forum.com/u/FrankMurphy)\
**Post date:** [May 22, 2010, 4:48am UTC](https://www.ruby-forum.com/t/newbie-question-about-views-folder/189024/3 "2010-05-22T04:48:27Z")

</div>

On May 22, 2:45 am, FrankMurphy [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> planet?  
> Deploying an app to a sub uri (rather than to the root of your domain)  
> is not the simplest case - you might want to try that first to  
> reassure yourself that everything is basically working. What you’ve  
> done doesn’t seem to quite match the instructions at  
> [Phusion Passenger users guide, Apache version](http://www.modrails.com/documentation/Users%20guide%20Apache.html#deploying_rails_to_sub_uri)

Fred

---

<div class="post-metadata">

**Author:** ![FrankMurphy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e99b99/32.png) [@FrankMurphy](https://www.ruby-forum.com/u/FrankMurphy)\
**Post date:** [May 22, 2010, 4:53am UTC](https://www.ruby-forum.com/t/newbie-question-about-views-folder/189024/4 "2010-05-22T04:53:08Z")

</div>

Hi Fred,

On Fri, May 21, 2010 at 9:47 PM, Frederick C. \<  
removed\_email\_address@domain.invalid\> wrote:

> On May 22, 2:45 am, FrankMurphy [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Deploying an app to a sub uri (rather than to the root of your domain)
> 
> I missed that. Excellent catch, as always.

Best regards,  
Bill

---

<div class="post-metadata">

**Author:** ![FrankMurphy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e99b99/32.png) [@FrankMurphy](https://www.ruby-forum.com/u/FrankMurphy)\
**Post date:** [May 22, 2010, 5:14am UTC](https://www.ruby-forum.com/t/newbie-question-about-views-folder/189024/5 "2010-05-22T05:14:47Z")

</div>

On Fri, May 21, 2010 at 06:45:11PM -0700, FrankMurphy wrote:

> http://\<server\_addr\>/demo\_app,  
> That’s a good sign.

> but http://\<server\_addr\>/demo\_app/users gives me a 404 Not Found.

Did you generate the new scaffold after your app was already running  
under  
Passenger? If so, and it’s environment is set to production, did you  
modify  
the tmp/restart.txt file in your app to signal Passenger to restart the  
application?

> but when I build this app locally and view it with Mongrel, I can see  
> [http://0.0.0.0:3000/users](http://0.0.0.0:3000/users) just fine.

That’s probably also a good sign. I bet you just need to have Passenger  
reload the app as mentioned above. Details can be found at:

[http://www.modrails.com/documentation/Users%20guide.html#\_redeploying\_restarting\_the\_ruby\_on\_rails\_application](http://www.modrails.com/documentation/Users%20guide.html#_redeploying_restarting_the_ruby_on_rails_application)

–

Kevin  
[http://www.RawFedDogs.net](http://www.RawFedDogs.net)  
[http://www.WacoAgilityGroup.org](http://www.WacoAgilityGroup.org)  
Bruceville, TX

What’s the definition of a legacy system? One that works!  
Errare humanum est, ignoscere caninum.

---

<div class="post-metadata">

**Author:** ![FrankMurphy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e99b99/32.png) [@FrankMurphy](https://www.ruby-forum.com/u/FrankMurphy)\
**Post date:** [May 22, 2010, 8:17pm UTC](https://www.ruby-forum.com/t/newbie-question-about-views-folder/189024/6 "2010-05-22T20:17:28Z")

</div>

FrankMurphy wrote:

> Thanks everyone for your replies.
> 
> Okay, so this is interesting. When I try deploying the app to the  
> domain root, I can’t see the “Welcome aboard!” page; instead, I see  
> the index.html page that’s in Apache’s web root directory. Also, when  
> I try http://\<server\_addr\>/users, I see a directory listing of the  
> (.erb) files that are in the demo\_app/app/views/users. Does this mean  
> that Passenger is not set up correctly?

Yes.

For your own sanity, set up Rails on your local box and don’t worry  
about the remote server yet.

> I don’t know if it matters, but the server I’m using doesn’t have a  
> domain name; I’m accessing it using its IP address.

Shouldn’t matter.

> On May 21, 7:47ï¿½pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![FrankMurphy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e99b99/32.png) [@FrankMurphy](https://www.ruby-forum.com/u/FrankMurphy)\
**Post date:** [May 23, 2010, 2:37am UTC](https://www.ruby-forum.com/t/newbie-question-about-views-folder/189024/7 "2010-05-23T02:37:11Z")

</div>

Okay, I got it to work on the domain root by editing /etc/apache2/  
sites-available/default to point to the app’s public directory. Is  
that the right way to go about it, or is that just a hack? If that’s  
what I’m supposed to do, it seems odd that this step isn’t mentioned  
in the mod\_rails user guide. I still can’t get it to work on a sub-uri  
using an analogous technique (i.e., creating a virtual host file for  
the URI in /etc/apache2/sites-available)…

---

<div class="post-metadata">

**Author:** ![FrankMurphy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e99b99/32.png) [@FrankMurphy](https://www.ruby-forum.com/u/FrankMurphy)\
**Post date:** [May 22, 2010, 6:26am UTC](https://www.ruby-forum.com/t/newbie-question-about-views-folder/189024/8 "2010-05-22T06:26:46Z")

</div>

Thanks everyone for your replies.

Okay, so this is interesting. When I try deploying the app to the  
domain root, I can’t see the “Welcome aboard!” page; instead, I see  
the index.html page that’s in Apache’s web root directory. Also, when  
I try http://\<server\_addr\>/users, I see a directory listing of the  
(.erb) files that are in the demo\_app/app/views/users. Does this mean  
that Passenger is not set up correctly?

I don’t know if it matters, but the server I’m using doesn’t have a  
domain name; I’m accessing it using its IP address.

On May 21, 7:47 pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![FrankMurphy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e99b99/32.png) [@FrankMurphy](https://www.ruby-forum.com/u/FrankMurphy)\
**Post date:** [May 23, 2010, 5:13pm UTC](https://www.ruby-forum.com/t/newbie-question-about-views-folder/189024/9 "2010-05-23T17:13:52Z")

</div>

On Sat, May 22, 2010 at 8:35 PM, FrankMurphy [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > Thanks everyone for your replies.
> > 
> > Okay, so this is interesting. When I try deploying the app to the  
> > domain root, I can’t see the “Welcome aboard!” page; instead, I see  
> > the index.html page that’s in Apache’s web root directory. Also, when  
> > I try http://\<server\_addr\>/users, I see a directory listing of the  
> > (.erb) files that are in the demo\_app/app/views/users. Does this mean  
> > that Passenger is not set up correctly?
> > 
> > I don’t know if it matters, but the server I’m using doesn’t have a  
> > domain name; I’m accessing it using its IP address.

Yes I think that matters, in the example you gave in the first post you  
had

\<VirtualHost \*:80\>  
ServerName \<server\_addr\>  
DocumentRoot /projects/demo\_app/public  
RailsBaseURI /demo\_app

This is what Apache calls a name-based virtual host

[http://httpd.apache.org/docs/2.2/vhosts/name-based.html](http://httpd.apache.org/docs/2.2/vhosts/name-based.html)

If you use an ip address like 192.168.1.123 as the value for the  
ServerName directive, apache will do a reverse dns search to try to  
find a NAME.  
[http://httpd.apache.org/docs/2.2/mod/core.html#servername](http://httpd.apache.org/docs/2.2/mod/core.html#servername)

If the server actually has a unique ip address for the app, then you  
might look at setting up an ip address based virtual host after  
reading the caveats in the first section of the first url I cited.

But the simpler thing would probably be to use a name based vhost and  
configure the client’s dns to resolve the name to the ip address so  
you can use it in the browser urls.

Just putting a line in /etc/hosts (or the equivalent if the client is  
a doze machine) should be enough.

–  
Rick DeNatale

Blog: [http://talklikeaduck.denhaven2.com/](http://talklikeaduck.denhaven2.com/)  
Github: [rubyredrick (Rick DeNatale) · GitHub](http://github.com/rubyredrick)  
Twitter: @RickDeNatale  
WWR: [http://www.workingwithrails.com/person/9021-rick-denatale](http://www.workingwithrails.com/person/9021-rick-denatale)  
LinkedIn: [http://www.linkedin.com/in/rickdenatale](http://www.linkedin.com/in/rickdenatale)
