-
Notifications
You must be signed in to change notification settings - Fork 9
Accessing components in the frontend
Gabriel Cardoso edited this page Sep 15, 2016
·
3 revisions
You'll sometimes need to access a component from the frontend, often to fetch it's associated model or models.
Say you defined the following config/components.rb
(for more informations on this file, see Components Configuration) :
section :main_menu do
component :configuration, :form, model_type: 'Configuration'
component :informations, :crud, model_type: 'Page', namespaced: true
end
Para then defines a method on the Para.components
object with the same name as the identifier. So you can call Para.components.configuration
to get you :configuration
component.
Here's an example usage :
class SomeController < ApplicationController
def index
# Get the configuration model
@configuration = Para.components.configuration.resource
# Get the pages from the Informations component
@information_pages = Para.components.informations.resources
end
end