This guide shows you how to add matestack-ui-core to an existing rails application.
Add 'matestack-ui-core' to your Gemfile
gem 'matestack-ui-core', '~> 1.0.0'
$ bundle install
Rails 6+ apps use webpacker by default. Rails 5 and below apps use the asset pipeline by default.
Add 'matestack-ui-core' to your
package.json by running:
$ yarn add https://github.com/matestack/matestack-ui-core#v1.0.0 $ yarn install
bundle info matestack-ui-core.
Next, import 'matestack-ui-core' in your
import MatestackUiCore from 'matestack-ui-core'
When you update the matestack-ui-core gem, make sure to update the npm package as well.
Require 'matestack-ui-core' in your
//= require matestack-ui-core
We recommend to (remove/deactivate)(https://stackoverflow.com/a/38649595) turbolinks, as there is no reason to use it alongside matestack-ui-core and there might appear some strange side effects. If you encounter strange page-transition/form-submit/action-submit behavior and have turbolinks activated, try to deactivate it first.
Create a folder called 'matestack' in your app directory. All your matestack apps, pages and components will be defined there.
Add the matestack helper to your controllers. If you want to make the helpers available in all controllers, add it to your 'ApplicationController' this way:
class ApplicationController < ActionController::Base include Matestack::Ui::Core::ApplicationHelper #... end
You need to add the ID "matestack-ui" to some part of your application layout (or any layout you use)
For Example, your
app/views/layouts/application.html.erb should look like this:
Don't apply the "matestack-ui" id to the body tag.
If you want to use websockets, please read our action cable guide.
That's all you need to setup matestack!