Rails on remote Apache server not displaying index.html.erb - ruby-on-rails

I played around with Rails on my laptop (running Linux + Apache + MySQL) and had no trouble getting the Getting Started with Rails tutorial to work locally. Now I'm trying the same thing at work on a remote Mac OS X + Apache server, and things aren't quite so rosy.
I typed rails blog -d mysql to create a directory called blog in /Library/WebServer/Documents/mydirectory. The trouble is, if I go to server.com/mydirectory/public, I get the public/index.html in my browser. But, I don't get this file if I go to server.com/mydirectory/. Instead, I get a 403 error. Also, when I:
script/generate controller home index
to create:
app/views/home/index.html.erb
I am unable to view this file, whether I go to server.com/mydirectory/home/index, or if I add a new line (map.root :controller => "home") to config/routes.rb and go to server.com/mydirectory.
Am I missing something really obvious about Apache and Rails?

Apache does not support Rails out of the box. You have to get mod_rails aka Passenger installed. Or, you could just use the server that comes with Rails, which is much easier (but not suitable for production). To do this, go to your directory and do ./script/server.

Related

I have a complete ruby project on my system but how do I run it?

I have a complete ruby project on my system that I downloaded from github.com and I want to run it on my Windows machine.
I have already installed Ruby and Rails on my system, but I have no idea how to run this project. The directory of this project is something like:
C:\Users\{username}\Desktop\BitcoinFundi\BitcoinFundi
How would I run this project on my system?
To run your Ruby on Rails application, use the following command:
rails server
This will start the server and you will be able to access the application in your browser at http://localhost:3000. Port 3000 is default and you can change it in the application settings.
To run a Ruby script use:
ruby name_of_script.rb
You should check out various resources and tutorials on getting started with rails.
As you say in your comment this is your first experience with Ruby on Rails, I think you should follow through chapter 1 and 2 (at least) of Ruby on Rails Tutorial. After that you should have a better understanding of how you start up a rails app and configure the DB. You also need a bunch of other libraries and software such as mysql from the sounds of it.
You should also read Getting Started with Rails. Section 4 covers how to start the default rails server.
Here is a guide on setting up a Rails environment for Windows, which is one of many guides, that shows you some of the needed steps to get a fully working environment.

Rails application issue after deployment - 404 error

I'm new to RoR.
I was able to install Rails and host it in Webrick (Sample App with "Welcome" controller) in my windows.
Now i have a Unix Weblogic Server along with a dedicated domian.
After exporting the .WAR file using Warbler, i accessed the Oracle Admin Console from where i deployed the .WAR file in the dedicated domain. I did all this for the Sample app with only the Welcome controller in it.
But even after deploying the WAR file, on accessing the Domain along with the Port Number (:9002) i ended up with 404 file not found error On looking at the server logs,there wasn't any records relating to any error. The Application must have been deployed properly. I assume that i must have missed out on some basic configurations in the routes.rb or similar files before deploying. Can anyone Guess what are all the possibilities and if possible can anyone help me by pointing to any tuts that cover the Steps to be carried out for configuration before deployment. do i need to install both JRuby and Rails inside the server before depolyment?
I can't really guess with Eror 404 only.
You can try mapping your rails app rack config to a different base_uri.
All you need to do is wrap the existing 'run' command in a map block
try doing this in your rails 'config.ru' file:
map '/mydepartment' do
run Myapp::Application
end
Now when you 'rails server' the app should be at localhost:3000/mydepartment .
Not sure if this will give you the desired outcome, but worth a try.
One more thing you also add this to your config/environments/production.rb and config/environments/development.rb (if on production mode):
config.action_controller.asset_path = proc { |path| "/abc#{path}" }
otherwise when you call your helpers such as stylesheet_link_tag in your views, they will generate links without the "/abc".
Also, find some guides you may refer for good support.
JRubyOnRailsOnBEAWeblogic.
Use JRuby with JMX for Oracle WebLogic Server 11g
Let me know if it is not resolved.

rails app - sudden 403 after pull - how do I start to debug?

I'm been working on a rails 3.1 app with one other dev.
I've just pulled some of his recent changes, using git. And am now getting a 403 on any page I try to visit.
You don't have permission to access / on this server.
I'm running the site locally through passenger.
Oddly, when I start the app using rails' internal server. I can visit the site at http://0.0.0.0:3000
Looking at the changes in this recent pull, the only files have changed are some javascripts, some html the application.rb, routes.rb and a rake file.
How do I debug this, I'm a bit lost on where to start?
EDIT:
If I roll back to an earlier version the site works, through passenger. Which leads me to believe the problem is within the rails app, rather than an Apache error. Or it could be a permissions thing, can git change file permissions in this way?
IMHO this is a configuration error in Apache or wrong directory layouts. Make sure that the passenger_base_uri still points to the public folder inside your rails project and that there are no hidden .htaccess files which block access. Also verify that your sym-links are correct (if there are any). Also check your Apache error log.
Start by launching your console to see if rails and your app can be loaded.
In your application root directory type :
rails console

Running Ruby on Rails from subdomain

I must be missing something, but RoR is just not working for me at all. I have RoR installed where I am hosting, and I have done all of the following:
cd ~
rails rubyonrails
ln -s rubyonrails www/rubyonrails/rails
Added to rubyonrails/public/.htaccess
RailsBaseURI /rubyonrails
Then:
cd rubyonrails
script/generate model User
script/generate controller User list
When I go to http://rubyonrails.truthanduntruth.com/rails/ it seems like it's just not running RoR at all. This might have to do with the fact that I'm using the subdomain. I set up the subdomain with cpanel, so I'm not sure how it's done. The subdomain folder itself is in /home/public_html/rubyonrails
So you can also go to http://truthanduntruth.com/rubyonrails/rails/ . Instead this gives me an error page. This is no better. Based on the error page or my steps above, can anyone tell what I am missing or where I am going wrong?
I'd like to at least get RoR running at all so I can learn it, but preferably I want it to run under the subdomain.
Thanks.

Apache/Rails/Passenger Displaying Site Index?

I have a Rails app that I have successfully tested with Mongrel and Webkit. Now I want to test deployment. I set up a VMWare Image using Ubuntu 8.04. I have installed Rails following this method https://help.ubuntu.com/community/RubyOnRails with the exception of using Gems 1.3 instead of 1.2. I have configured and installed Passenger. However, when I visit my sites index (http://some.ip.that.i'm.testing/) I simply get the directory index of my rails site. I should note that since I'm testing I just dumped my app in /var/www.
My Apache2 error.log file shows this and this only:
[Tue Sep 30 15:10:41 2008] [notice] Apache/2.2.8 (Ubuntu) Phusion_Passenger/2.0.3 configured -- resuming normal operations
Any idea what could be causing this problem? It seems Passenger is configured properly, but I'm not sure why my rails app is not displaying and why the site's directory listing is.
Thanks.
Two questions:
1) Is Rails running at all on the server? Passenger should start Rails automatically on first request - if you do a ps, do you see it running?
2) Which directory are you seeing - is it your rails directory or the public/ directory? If it's the former, your symlink is likely pointing the wrong place (it should go to public/).
(I've seen this problem before and am trying to remember how I debugged it... these are my first two thoughts.)

Resources