Creating a New Rails Application

This guide assumes that a fully functional installation of Infopark CMS Fiona exists. Please also take account of the installation requirements.

  1. Install the application and the components on which it depends

    First, create a new Rails application:
    $ rails new myProject --skip-bundle
    
    Change into the newly created directory of your project:
    $ cd myProject
    
    Add the required Infopark Rails Connector gems to the Gemfile:
    gem 'mysql2'
    gem 'infopark_rails_connector', '~> x.y.z'
    gem 'infopark_fiona_connector', '~> x.y.z'
    
    Then install the additional software:
    $ bundle install
    
    Up to version 6.8.0: Copy your license file, license.xml, to the config directory.
  2. Prepare the Infopark CMS Fiona database

    For the Rails Connector to access the data of the Content Manager (CM), its database needs to be changed to MySQL and optimized for the Rails Connector. To do so, change into the directory of the instance and execute the following command:
    # The preconfigured instance name is "default".
    $ cd FIONA/instance/instanceName
    $ ./bin/CM -railsify
    
    Since Infopark Rails Connector only reads from the CM database, we recommend creating a separate read-only database user for the application. You can create one using the following commands:
    $ mysql -u root -p
    Enter password:
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 18
    Server version: 5.0.41-community MySQL Community Edition (GPL)
    Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
    mysql> grant read on fiona_cm.* to fiona_cm_ro@localhost identified by 'fiona_cm_ro';
    
  3. Create additional databases for the Rails application

    Create additional databases for the live data by means of the following commands. You require such a database for every environment (development, production, preview, test).
    $ mysql -u root -p
    Enter password:
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 18
    Server version: 5.0.41-community MySQL Community Edition (GPL)
    Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
    mysql> create database myProject_development;
    Query OK, 1 row affected (0.00 sec)
    mysql> grant all on myProject_development.* to fiona@localhost identified by 'fiona';
    Query OK, 1 row affected (0.00 sec)
    mysql> create database myProject_production;
    Query OK, 1 row affected (0.00 sec)
    mysql> grant all on myProject_production.* to fiona@localhost identified by 'fiona';
    Query OK, 1 row affected (0.00 sec)
    mysql> create database myProject_preview;
    Query OK, 1 row affected (0.00 sec)
    mysql> grant all on myProject_preview.* to fiona@localhost identified by 'fiona';
    Query OK, 1 row affected (0.00 sec)
    mysql> create database myProject_test;
    Query OK, 1 row affected (0.00 sec)
    mysql> grant all on myProject_test.* to fiona@localhost identified by 'fiona';
    Query OK, 1 row affected (0.00 sec)
    mysql> exit
    Bye
    
  4. Adjust the database connection

    In conjunction with Infopark Rails Connector, your Rails application uses two databases each of which needs to be configured in every environment:
    • One database for the CMS content (cms)
    • One database for the application specific content (development, production, preview or test)
    The configuration for the database connection is located in the config/database.yml file. Adjust its content according to your database setup.
    cms:
       adapter: mysql2
       database: fiona_cm
       username: fiona_cm_ro
       password: fiona_cm_ro
       encoding: utf8
       host: YOUR_CMS_DATABASE_SERVER
    development:
       adapter: mysql2
       database: myProject_development
       username: fiona
       password: fiona
       encoding: utf8
       host: YOUR_RAILS_DATABASE_SERVER
    test:
       adapter: mysql2
       database: myProject_test
       username: fiona
       password: fiona
       encoding: utf8
       host: YOUR_RAILS_DATABASE_SERVER
    production:
       adapter: mysql2
       database: myProject_production
       username: fiona
       password: fiona
       encoding: utf8
       host: YOUR_RAILS_DATABASE_SERVER
    preview:
       adapter: mysql2
       database: myProject_preview
       username: fiona
       password: fiona
       encoding: utf8
       host: YOUR_RAILS_DATABASE_SERVER
    
  5. Finish the Rails Connector installation

    Change back into the main directory of the rails application and trigger the automatic installation of the Rails Connector:
    $ cd myProject
    $ rails generate rails_connector:install
          create  config/initializers/rails_connector.rb
          create  app/models/obj.rb
          create  config/local/configuration.rb
          append  app/assets/javascripts/application.js
            gsub  app/assets/stylesheets/application.css
          remove  public/index.html
          remove  app/assets/images/rails.png
            gsub  app/views/layouts/application.html.erb
            gsub  app/views/layouts/application.html.erb
    
    This generator creates the additional files required or provided by the Rails Connector.
  6. Adjust CMS instance configuration

    Unless you are using the default instance, specify the instance name the Rails Connector should use in the config/initializer/rails_connector.rb file:
    RailsConnector::Configuration.instance_name = "instanceName" 
  7. Set up preview environment

    To have the CMS preview delivered by Infopark Rails Connector, you require a suitable Rails environment. We recommend to derive it from the production environment by making a copy of the production.rb file:
    $ cp config/environments/production.rb config/environments/preview.rb
     To change the Rails Connector mode, add this line to the copied environment file:
    RailsConnector::Configuration.mode = "editor"
  8. Test the application

    Start the application server in the development environment using the following command:
    $ rails s
    => Booting WEBrick
    => Rails 3.2.19 application starting in development on http://0.0.0.0:3000 Call with -d to detach
    => Ctrl-C to shutdown server
    Test the opeability of the application by requesting the start page at http://localhost:3000/.
  9. Integrate the Rails preview

    Integrate the Rails preview into the CMS GUI.