-
Notifications
You must be signed in to change notification settings - Fork 9
Creating components
vala edited this page Dec 5, 2014
·
12 revisions
WIP ...
Para works with components. To generate one, use the following command
rails g para:component ComponentName
Once you created a component, run this generator should you need to associate that component with a resource
rails g para:resource ResourceName ComponentName title:string description:text
In the generated resource controller, the resource name is already assigned.
It automatically uses CanCan under the hood to load and authorize the resource.
You can pass the same parameters to the macro as the
load_and_authorize_resource
CanCan macro.
Here is the default behavior, the options hash being the default one and not written directly in the generated controller.
class YourResourcesController < Para::Admin::ResourcesController
resource :your_resource, through: :component, class: 'YourResource',
parent: false
end
Components and resources work out of the box with CRUD. If you need to overide the show page, here is how
rails g para:table ResourceName
And in case you want to change the way the form works, this generator can be helpful
rails g para:form ResourceName