|
|
## Steps
|
|
|
|
|
|
Log into `glenn.osc.edu`, then:
|
|
|
|
|
|
1. [Setup new rails project with passenger](#1-setup-new-rails-project-with-passenger)
|
|
|
2. [Add hello world view and route](#2-add-hello-world-view-and-route)
|
|
|
3. [Work around the root directory config defect](#3-work-around-the-root-directory-config-defect)
|
|
|
|
|
|
### 1. Setup new rails project with passenger
|
|
|
|
|
|
_Make sure you add the .htaccess file as described at the bottom of this section before accessing the app through https://apps.awesim.org/devapps_
|
|
|
|
|
|
Log into `glenn.osc.edu`
|
|
|
|
|
|
Load ruby module and move into awesim_dev directory:
|
|
|
```
|
|
|
-bash-3.2$ cd ~/awesim_dev
|
|
|
-bash-3.2$ module load ruby-2.0.0-p247
|
|
|
```
|
|
|
|
|
|
Start a new project to work with passenger (NOTE: the rails1 directory should not be created before running the mv command below or the files will not copy correctly):
|
|
|
```
|
|
|
-bash-3.2$ rails new hello --skip-bundle
|
|
|
```
|
|
|
|
|
|
Then we want to rename this directory to `rails1` (if `rails1` already exists, move the contents of `hello` to the contents of `rails1` instead):
|
|
|
|
|
|
```
|
|
|
-bash-3.2$ mv hello rails1
|
|
|
-bash-3.2$ cd rails1
|
|
|
-bash-3.2$ ls
|
|
|
app bin config config.ru db Gemfile Gemfile.lock lib log public Rakefile README.rdoc test tmp vendor
|
|
|
```
|
|
|
|
|
|
Finally `bundle install` to update the `Gemfile.lock` file:
|
|
|
|
|
|
```
|
|
|
-bash-3.2$ bundle install --local
|
|
|
```
|
|
|
|
|
|
Init git repo:
|
|
|
|
|
|
```
|
|
|
-bash-3.2$ git init
|
|
|
Initialized empty Git repository in /nfs/17/efranz/awesim_dev/rails3/.git/
|
|
|
-bash-3.2$ git add .
|
|
|
-bash-3.2$ git commit -m "initial commit"
|
|
|
```
|
|
|
|
|
|
If you try to do something like use `rails generate` you will probably see this:
|
|
|
|
|
|
```
|
|
|
/usr/local/ruby/2.0.0-p247/lib/ruby/gems/2.0.0/gems/execjs-2.0.2/lib/execjs/runtimes.rb:51:in `autodetect': Could not find a JavaScript runtime.
|
|
|
```
|
|
|
|
|
|
For now, use `therubyracer` gem. Later we will offer node.js as a JS runtime environment which will be more robust. Edit the file `Gemfile` and uncomment this line:
|
|
|
|
|
|
```
|
|
|
# gem 'therubyracer', platforms: :ruby
|
|
|
```
|
|
|
|
|
|
Then bundle install:
|
|
|
|
|
|
```
|
|
|
-bash-3.2$ bundle install --local
|
|
|
Resolving dependencies...
|
|
|
Using rake (10.1.0)
|
|
|
Using i18n (0.6.5)
|
|
|
...
|
|
|
Using therubyracer (0.12.0)
|
|
|
Using turbolinks (1.3.0)
|
|
|
Using uglifier (2.2.1)
|
|
|
Your bundle is complete!
|
|
|
Use `bundle show [gemname]` to see where a bundled gem is installed.
|
|
|
-bash-3.2$ git status
|
|
|
# On branch master
|
|
|
# Changes not staged for commit:
|
|
|
# (use "git add <file>..." to update what will be committed)
|
|
|
# (use "git checkout -- <file>..." to discard changes in working directory)
|
|
|
#
|
|
|
# modified: Gemfile
|
|
|
# modified: Gemfile.lock
|
|
|
#
|
|
|
no changes added to commit (use "git add" and/or "git commit -a")
|
|
|
-bash-3.2$ git add .
|
|
|
-bash-3.2$ git commit -m "add ruby racer"
|
|
|
[master ee001cd] add ruby racer
|
|
|
2 files changed, 7 insertions(+), 1 deletion(-)
|
|
|
-bash-3.2$
|
|
|
```
|
|
|
|
|
|
#### Add .htaccess file
|
|
|
|
|
|
Finally, add a .htaccess file to:
|
|
|
|
|
|
* set development mode on passenger: [[WSGI and Rack apps in development mode]]
|
|
|
* ensure restarting the passenger app works via `touch tmp/restart.txt`: [[htaccess modification for restarting passenger apps]]
|
|
|
|
|
|
### 2. Add hello world view and route
|
|
|
|
|
|
```
|
|
|
-bash-3.2$ rails g controller pages index
|
|
|
```
|
|
|
|
|
|
Now you can access this page via:
|
|
|
https://websvcs02.osc.edu/awesim_dev/rails1/pages/index
|
|
|
|
|
|
_* https://websvcs02.osc.edu is not a permanent address - the domain for development PUAs may change in the future_
|
|
|
|
|
|
|
|
|
### 3. Work around the root directory config defect
|
|
|
|
|
|
Going here results in an error "Service Temporarily Unavailable":
|
|
|
|
|
|
* https://websvcs02.osc.edu/awesim_dev/rails1/
|
|
|
|
|
|
|
|
|
Add namespace to your routes that matches the original name of your app. In our case it was "hello":
|
|
|
|
|
|
```ruby
|
|
|
Hello::Application.routes.draw do
|
|
|
scope 'hello' do
|
|
|
get "pages/index"
|
|
|
root 'pages#index'
|
|
|
end
|
|
|
end
|
|
|
```
|
|
|
|
|
|
Now when you go to /rails1/hello you will get the index page, and root is set to this location. Finally, replace the default public/index.html page with this redirect page:
|
|
|
|
|
|
```
|
|
|
<html>
|
|
|
<head>
|
|
|
<meta http-equiv="REFRESH" content="0;url=hello/"/>
|
|
|
<title></title>
|
|
|
</head>
|
|
|
<body>
|
|
|
</body>
|
|
|
</html>
|
|
|
```
|
|
|
|
|
|
Where url is set to the namespace of your app.
|
|
|
|
|
|
Now when you go to:
|
|
|
|
|
|
* https://websvcs02.osc.edu/awesim_dev/rails1/
|
|
|
|
|
|
it auto redirects to the root of your app at
|
|
|
|
|
|
* https://websvcs02.osc.edu/awesim_dev/rails1/hello
|
|
|
|
|
|
Which shows the PagesController's index page. This is also currently set in the routes to be accessible via:
|
|
|
|
|
|
* https://websvcs02.osc.edu/awesim_dev/rails1/hello/pages/index |
|
|
\ No newline at end of file |