Running Ruby on Rails from subdomain - ruby-on-rails

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.

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 4.0 receiving emails - no such file (runner)

Up until now I've been using script/runner to forward bouncebacks to eblast-bounceback#mydomain.com and eblast-bounceback#dev.mydomain.com. However it is no longer working in Rails 4.0. I also can't seem to find a good resource online to illustrate how to do it. I usually get directed to the 'whenever' gem - but that's for cron jobs, not for 'piping to programs'.
So this is essentially what I'm currently doing, but is failing:
|/home/user/rails/dev.www/script/rails runner 'EBlast.receive(STDIN.read)' -e development
How do I get this to work? I'm not on Rails 4.1, I'm on 4.0. FWIW I do not have bin/rails. The above command yields "no such file or directory".
There were actually a few things I needed to do.
The email eblast-bounce#dev.mydomain.com was considered 'unroutable'. At first I figured it was because there wasn't any MX records for the subdomain, so I added one. But then I still got the error. I had manually updated the aliases file in /etc/valiases to pipe to the program using a symlinked directory (because I was deploying with Capistrano, and the directory ends up changing after every deploy). Turns out symlinks don't work for some reason when it comes to exim routing (/home/me/rails_deployments/dev.www/current/bin/rails fails). Maybe I'm wrong about the symlinks thing but the problem went away when I used the solution below.
This problem however was solved when I eventually came to another problem (/usr/bin/env: ruby: No such file or directory). I'm using RVM to manage rubies/gems, and apparently the email forwarder didn't know what ruby was. This leads to the final solution:
(when in cPanel, "pipe to program" assumes the user home directory (/home/me/))
.rvm/wrappers/ruby-2.1.0#website/ruby /home/me/rails_deployments/dev.www/current/bin/rails runner 'EBlast.receive(STDIN.read)' -e development
Where ruby-2.1.0 is my current ruby version, and #website is the gemset used by the EBlast.receive code base.
EDIT: Spoke too soon, the command has its own set of problems...(gemfile not present). This is ludicrous.

Error: Rails command not found

I created a new Rails project in a directory, say Desktop (rails new project1). After that, I ran the following command:
rails server
Then, the project1 was running on localhost.
After that, I made another directory with name (project1) in another location. I copied all the files from the previous location to new location. After that, when I ran the following command:
rails server
I got the following error message:
Rails is not currently installed on this system.
But it is working in the previous directory. How do I solve this?
If you are totally new to Rails development and System administration it is rather complicated in the beginning. I recommend any kind of Rails tutorial to you for examply by Michael Hartl .
As Graeme McLean points out you somewhen understand that there is information about your environment needed to help you.
Most likely the requirements you need to be set up are not set up in the place you did copy your rails project as Pavan and Thaha kp pointed out.

rails beginner, created 2 rails app on local dev

I am new to rails and I was able to install rails (3.2.3, ruby v1.9.3), then created a test app:
$ rails new Hello
then I cd'd into the new directory 'hello' and did the following commands:
$ rails generate controller home index
$ rails s
$ rake routes, it gave me
home_index GET /home/index(.:format) home#index
hello /hello(.:format) Hello#index
Then I pointed my browser to: http://localhost:3000/home/index - and it worked great.
Then I wanted to begin a tutorial and it asked me to create a new rails application
so I did like I did before...
$ rails new TutorialApp
$ rails generate controller tutorial index
$ rails s
$ rake routes, it gave me
tutorial_index GET /tutorial/index(.:format) tutorial#index
then I pointed my browser to: http://localhost:3000/tutorial/index, it gave me a message of
Routing Error
No route matches [GET] "/tutorial/index" Try running rake routes for
more information on available routes.
So I ran rake routes again, which it gave me the same output as it did before
tutorial_index GET /tutorial/index(.:format) tutorial#index
Since I created that first rails app "Hello", do I need to turn off that app before starting the new rails app "Tutorial" or they can both be running at the same time?
Any help is appreciated, thanks!
You can use a different port
rails server -p 3001
It will run in a different port. Then, just point to http://localhost:3001
But usually you will probably stop the server on one app and start the other one. It's up to you.
When you run rails server ("rails s"), you're typically running it in the context of the rails project you're in at the time, so before beginning a new project, I would shut down the current server (CTRL C). Also, make sure you create a new rails app in a folder is isn't itself at the root of a rails app. It looks like you might have created your tutorial app inside the root of your Hello app. Sounds like those are the two main things that tripped you up.

Rails on remote Apache server not displaying index.html.erb

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.

Resources