Instantly share code, notes, and snippets.

Embed
What would you like to do?
Capistrano Deployment with DesignModo's FlatUI Pro framework

This is for those having trouble with the 'designmodo-flatuipro-rails' gem in a rails app when using Capistrano for deployment.

This gem required that we use the 'less' gem in conjunction with the 'bootstrap-on-rails' gem. This bootstrap gem is the Less version.

The error we are dealing with is this: couldn't find file 'jquery.ui.touch-punch.min'

All of the work will be done in the 'config/deploy.rb' file

after "deploy:bundle_gems", "deploy:flat_ui"
before "deploy:assets:precompile", "deploy:flat_ui"
 
namespace :deploy do
 
  task :flat_ui do
    run "cd #{deploy_to}/shared/bundle/ruby/2.1.0/gems/designmodo-flatuipro-rails-1.2.2.0.branch/app/assets && rm -rf *"
    run "cd #{release_path} && bundle exec rails generate flatuipro:install #{deploy_to}/flatui"
    run "cd #{release_path}/app/assets/stylesheets && rm application.css"
  end
  
  task :setup_config, roles: :app do
    sudo "ln -nfs #{current_path}/config/nginx.conf /etc/nginx/sites-enabled/#{application}"
    sudo "ln -nfs #{current_path}/config/unicorn_init.sh /etc/init.d/unicorn_#{application}"
    run "mkdir -p #{shared_path}/config"
    put File.read("config/database.example.yml"), "#{shared_path}/config/database.yml"
    puts "Now edit #{shared_path}/config/database.yml and add your username and password"
  end
  after "deploy:setup", "deploy:setup_config"
  before "deploy:flatui", "deploy:setup_config"
end

Here's some explanations:

run "cd #{deploy_to}/shared/bundle/ruby/2.1.0/gems/designmodo-flatuipro-rails-1.2.2.0.branch/app/assets && rm -rf *"

This line deletes the assets that are created in the shared folder for the gem. I do this b/c you get conflicts when you deploy after the initial deploy when the 'flatiupro:install' function is run. You could probably add code to NOT run the install if the files are already in the shared gem folder.

run "cd #{release_path} && bundle exec rails generate flatuipro:install #{deploy_to}/flatui"

This is the function that installs the flatui files from the /home/username/apps/projectname/flatui(where I put the FlatUI Pro files on the server) to the release folder for the app. I got this function from this issue for the 'designmodo-flatuipro-rails' gem repo: Gem Issue

run "cd #{release_path}/app/assets/stylesheets && rm application.css"

This is run b/c you should have an 'application.less.css' file in your project and the flatuipro:install function places an 'application.css' file in your assets folder. During precompile if both files exist you will get a 'Sprockets::CircularDependencyError', so we run this to remove the 'application.css' file that is empty anyway.

after "deploy:bundle_gems", "deploy:flat_ui"

You can't run the flatuipro:install script before the gem has been installed.

before "deploy:flatui", "deploy:setup_config"

You will notice in the script that 'deploy:setup_config' create the shared folders. If you run flatuipro:install before 'deploy:setup_config', you'll get a 'file or folder doesn't exist error' for the shared folder b/c it hasn't been created yet.

before "deploy:assets:precompile", "deploy:flat_ui"

If you precompile before running the flatui task then you won't compile the flatui files.

I hope this helps!!!

--Eric

@kovacs

This comment has been minimized.

kovacs commented May 19, 2014

To be clear can you post what gems you need for this to work? I'm using:

gem 'less-rails-bootstrap'
gem 'designmodo-flatuipro-rails', '~> 1.2.5.0.branch'

@ericwindham

This comment has been minimized.

Owner

ericwindham commented Jul 17, 2014

Hi,

I'm really sorry. I just noticed your question. I was using the 1.2.2 branch of the designmodo-flatuipro-rails gem. The bootstrap gem I'm using is 'bootstrap-on-rails'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment