Git Product home page Git Product logo

rails-example's Introduction

Rails Sample App on OpenShift

Quickstart rails application for openshift.

The easiest way to install this application is to use the [OpenShift Instant Application][template]. If you'd like to install it manually, follow these directions.

OpenShift Considerations

These are some special considerations you may need to keep in mind when running your application on OpenShift.

Database

Your application is configured to use your OpenShift database in Production mode. Because it addresses these databases based on OpenShift Environment Variables, you will need to change these if you want to use your application in Production mode outside of OpenShift.

Assets

Your application is set to precompile the assets every time you push to OpenShift. Any assets you commit to your repo will be preserved alongside those which are generated during the build.

By adding disable_asset_compilation marker, you will disable asset compilation upon application deployment.

Security

Since these quickstarts are shared code, we had to take special consideration to ensure that security related configuration variables was unique across applications. To accomplish this, we modified some of the configuration files (shown in the table below). Now instead of using the same default values, your application will generate it's own value using the initialize_secret function from lib/openshift_secret_generator.rb.

This function uses a secure environment variable that only exists on your deployed application and not in your code anywhere. You can then use the function to generate any variables you need. Each of them will be unique so initialize_secret(:a) will differ from initialize_secret(:b) but they will also be consistent, so any time your application uses them (even across reboots), you know they will be the same.

Development mode

When you develop your Rails application in OpenShift, you can also enable the 'development' environment by setting the RAILS_ENV environment variable, using the rhc client, like:

$ rhc env set RAILS_ENV=development

If you do so, OpenShift will run your application under 'development' mode. In development mode, your application will:

  • Show more detailed errors in browser
  • Skip static assets (re)compilation
  • Skip web server restart, as the code is reloaded automatically
  • Skip bundle command if the Gemfile is not modified

Development environment can help you debug problems in your application in the same way as you do when developing on your local machine. However, we strong advise you to not run your application in this mode in production.

Modified Files
File Variable
config/initializers/secret_token.rb Railsapp::Application.config.secret_token
config/initializers/session_store.rb Railsapp::Application.config.session_store

Manual Installation

  1. Create an account at https://www.openshift.com

  2. Create a rails application

    rhc app create railsapp ruby-1.9
    

    Note: To support Ruby 1.8,

    +++ config/initializers/wrap_parameters.rb
    @@ -5,7 +5,7 @@
     
      # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
       ActiveSupport.on_load(:action_controller) do
       -  wrap_parameters format: [:json]
       +  wrap_parameters ({:format => [:json]})
        end
    



1. Add database support to your application

  ```
  rhc cartridge add -a railsapp -c mysql-5.5
  ```

  or

  ```
  rhc cartridge add -a railsapp -c postgresql-9.2
  ```

1. Add this upstream Rails quickstart repository

  ```
  cd railsapp
  git remote add upstream -m master git://github.com/openshift/rails-example.git
  git pull -s recursive -X theirs upstream master
  ```

1. Push your new code

  ```
  git push
  ```

1. That's it! Enjoy your new Rails application!


[template]: https://openshift.redhat.com/app/console/application_types

License
-------

This code is dedicated to the public domain to the maximum extent permitted by applicable law, pursuant to CC0 (http://creativecommons.org/publicdomain/zero/1.0/)

rails-example's People

Contributors

banzaiman avatar danmcp avatar dblado avatar dereckson avatar devop-mmcgrath avatar gshipley avatar ironcladlou avatar jhadvig avatar jorris avatar jroes avatar jwhonce avatar kraman avatar kwoodson avatar mfojtik avatar mrunalp avatar ryanj avatar smarterclayton avatar thefotios avatar zaz avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.