Aspartame

Instructions:

  1. Add gem 'aspartame' to Gemfile and run bundle install.
  2. Run rails generate formtastic:install to get the forms working properly. Add to config/initializers/formtastic.rb Formtastic::Helpers::FormHelper.builder = FormtasticBootstrap::FormBuilder
  3. Run rake aspartame:install:migrations and then rake db:migrate
  4. Add mount Aspartame::Engine => "/aspartame" to main app's routes.rb.
  5. Add *= require aspartame/aspartame to main app's application.css file.
  6. Add <%= render 'layouts/aspartame/aspartame_header' %> at the top of the body of main app's application.html.erb file.
  7. Add include Aspartame::ApplicationHelper to your application_helper.rb.
  8. Add the following to your application_controller.rb:
before_filter :aspartame_form_variables

      def aspartame_form_variables
        @aspartame_translation = Aspartame::AspartameTranslation.new
        if request.fullpath.index('?') 
            @aspartame_url_string = request.fullpath.slice(0...(request.fullpath.index('?')))
        else
            @aspartame_url_string = request.fullpath
        end
        @aspartame_universal_translations = Aspartame::AspartameTranslation.where(:url => "UNIVERSAL", :language => params[:ln], :status => true)
        @aspartame_translations = Aspartame::AspartameTranslation.where(:url => @aspartame_url_string, :language => params[:ln], :status => true)
        @aspartame_user = Aspartame::AspartameUser.find_by_remember_token(cookies[:aspartame_remember_token])
      end

Major Issue: I could not figure out how to get the gem to load gem dependencies and application controller/helper. This is definitely on the list of to-dos, but until then, install any uninstalled gems below via your app's Gemfile:

gem "jquery-rails"
gem 'bootstrap-sass'
gem 'formtastic'
gem 'formtastic-bootstrap'
gem 'will_paginate'
gem 'bcrypt-ruby'
gem 'sass-rails'
gem 'jquery-datatables-rails', github: 'rweng/jquery-datatables-rails'
gem 'jquery-ui-rails'
gem 'coffee-rails'

RefineryCMS notes:

  • All instances of main_app.root_path must be replaced with refinery.root_path. For this reason, add gem 'aspartame-refinery' instead to Gemfile.

  • I had an issue with jQuery not being defined for $(document).ready calls. My problem was solved by moving the javascript inclusion in application.html.erb to the top of the body, above the _aspartame_header partial.