Installing Rails Designer
Installing Rails Designer 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 Rails Designer manually, follow the next steps.
1. Add the Rails Designer and Rails Icons gem to your Gemfile
source "https://get.railsdesigner.com/private" do
gem "rails_designer", "~> 1.10.0"
end
gem "rails_icons", "~> 1.0.0"
(rails_icons is optional, but really recommendeded!)
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 Rails Designer API 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 Rails Designer API key for basic authentication, as this method significantly increases the likelihood of it being exposed publicly.
3. Bundle to fetch the Rails Designer gem
bundle
4. Run the Rails Designer install command
rails generate rails_designer:install
This will create the configuration file config/initializer/rails_designer.rb
and add the route to the Rails Designer engine. Check out this article about the initializer.
5. Install the Rails Icons gem
This will create the rails_icons initializer and sync the heroicons library’s icons. If you don’t installed the rails_icons gem, you can skip this step.
rails generate rails_icons:install --libraries=heroicons
Contain Rails Designer to development
Rails Designer’s 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, are used from the gem. If you want to “lock” it down to only development, take the following steps:
Note: if you use any of the view helpers, make sure you have copied them into your app instead of using 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.10.0"
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