mkdir railsProjects && cd $_
rails new myrailsapp && cd $_
bundle install
rails s
# Check that all is well:
curl localhost:3000 | grep -i 'Welcome'
» <h1>:Welcome aboard</h1> # (abridged)
# Generate a scaffold
rails generate scaffold Product name:string description:text price:float
rake db:migrate
# Set the routes
sed -i "s/'welcome#index'/'products#index'/" config/routes.rb
sed -i 's/#\{1,2\}[[:space:]]\{0,10\}root/\ root/' config/routes.rb
# Open a remote port to public access
socat TCP-LISTEN:8090,fork TCP:localhost:3000
# Check that all is well
netcat -z -v localhost 8090
» Connection to localhost 8090 port [tcp/*] succeeded!
# On browser:
johndow.com:8090 # (ie server-name.com:port-number)
# From the browser, added some products
# The final result was something like the following:
Notes
Lynx, a text web browser, may be used instead of curl to check that all is well
Sed Commands
The sed commands used to programatically change text in config/routes.rb are specific to Ubuntu,and may not work as expected on the Mac OS, as the GNU and BSD versions of sed behave differently
The first command merely changes the default root 'welcome#index' to root 'products#index' in config/routes.rb
The second command uncomments the line (removes the '#') containing the word root in config.rb.
These changes may be easily made with any text editor or IDE, instead of using sed
Local access over ssh
Instead of using socat to open a port to public access, the Rails app was securely accessed over ssh as follows:
# On server:
rails s
# On local machine:
# (here a Windows 10 computer, using Powershell to execute ssh command. Putty will work equally well)
ssh -N -f -L localhost:4000:localhost:3000 janedow@johndow.com
# enter password
# On local browser (here Firefox running on Windows 10):
localhost:3000