Documentation

Installing Rails Designer

Installing Rails Designer’s UI Components Library can be done with just one command (keep your Rails Designer key ready):

rails app:template LOCATION="https://railsdesigner.com/setup/"

If you want to add it manually, follow these steps:

1. Add the gem to your Gemfile

source "https://get.railsdesigner.com/private" do
  gem "rails_designer", "~> 1.13.1"
end

2. Add the API Key you received via email

export BUNDLE_GET__RAILSDESIGNER__COM=<api_key>

This is using Bundler’s configuration keys under the hood. Other ways to store the private key are:

  • bundle config set --global get.railsdesigner.com <api_key>
  • or using basic authentication, like so: source "https://<api_key>@get.railsdesigner.com/private" do

It’s advised against employing the key for basic authentication, as this method significantly increases the likelihood of it being exposed publicly (which results in the key being revoked).

3. Bundle to fetch the gem

bundle

4. Run the install command

rails generate rails_designer:install

This will create the configuration file config/initializer/rails_designer.rb and add the route to the engine. Check out this article about the initializer.

Contain Rails Designer to development

The default set up only allows access in development, but the gem would still be installed/fetched in production. This is because certain features, like view helpers and the Form Builder, are used from the gem. If you want to “lock it down” to development, take the following steps:

Note: if you use the Form Builder this set up won’t work! If you use any of the view helpers, make sure you have copied them into your app instead of from the gem. Check out the generator on how to do it.

1. Move the gem into development group

group :development, :test do
  # …
  source "https://get.railsdesigner.com/private" do
    gem "rails_designer", "~> 1.13.1"
  end
end

2. Wrap the engine route

# config/routes.rb
if Rails.env.development?
  mount RailsDesigner::Engine, at: "/rails_designer"
end

3. Wrap the initializer

# config/initializers/rails_designer.rb
if defined?(RailsDesigner) && Rails.env.development?
  RailsDesigner.configure do |config|
    # Rest of the initializer
  end
end

Help

Use the --help flag to view the command’s help.

rails generate rails_designer:install --help