Getting started
Installation
🎉 Once you have purchased a license for Maglev PRO, you will receive an email containing the license key needed to install the Maglev PRO gem, along with instructions for adding this gem to your application's Gemfile.
Your application DB must be created first with bundle exec rails db:create
Add this line to your application's Gemfile:
Note: the license key is the one you got from the email you receive after the purchase. If you deleted the email, no worries, send us an email at contact@maglev.dev.
And then execute:
Prepare your app
Execute once the Maglev PRO installation generator within the folder of your rails app and follow screen instructions.
To function properly, Maglev PRO needs to identify which of your Rails models will own a Maglev site, as this varies depending on your business. 👋 If you are unsure, we are here to help you figure it out.
Create a theme and a first section
Create a first theme
and a dummy section
It's now time to run your Rails app server.
Please visit http://localhost:3000/maglev/admin, you will see your new theme and section.
[OPTIONAL] Embed a default theme in your application
The maglev-hyperui-kit
gem includes a library of marketing sections based on hyperui, a free open source tailwindcss components.
First, add the Maglev HyperUI kit gem to your Gemfile:
Then execute:
Now, install the theme and assign an id to it (default
in our example):
Create programmatically your first site
We'll assume that you want to offer a site for each instance of the Account model in your application. Remember that you have made the choice of the parent model during the installation.
We're now going to create a new Maglev site based on the Simple theme and link it to one of your accounts.
If you installed the MaglevCMS HyperUI kit theme from the previous chapter, you'll have to replace simple
by default
in the next statements.
Open your rails console
And type the following lines of Ruby code
In the next steps, inside your Rails application, you'll have to call the Maglev::Pro::GenerateSite service from one of your controller action, a model callback or your own service.
In order to get the editor UI url, in the Rails console, type:
It will return an url similar to this one: http://localhost:3000/maglev/black-wildflower-1100/editor/en/index.
However, most of the time, you will need to generate this link within your main application. If your site is mounted on your Account model, you should write something like:
Going further
Congratulations, you now have Maglev PRO up and running within your Rails application!
It's time to start writing the sections for your themes 💪🚀.
Please refer to the concepts and guides for more information.
Last updated