RailsAdminContentBuilderRails6
Easy way for create contents using rails_admin. This gem is an update of rails_admin_content_builder, it has bugfixes, improvements and now works on Rails 6.
Preview
Requirements
Dependencies
MiniMagick
Supported ORM
ActiveRecord
Supported Asset Plugin
CarrierWave
Installation
Add this line to your application's Gemfile:
gem 'rails_admin'
gem 'rails_admin_content_builder_rails_6'Run the generator and migrations
rails g rails_admin_content_builder
rake db:migrate
After running the generator, set the module like this in config -> initializers -> carrierwave.rb. This is used to low the quality of the image, leaving it light and you can use for all uploaders.
module CarrierWave
module MiniMagick
def quality(percentage)
manipulate! do |img|
img.quality(percentage.to_s)
img = yield(img) if block_given?
img
end
end
end
endAdd styles in app/assets/application.scss
*= require rails_admin_content_builderNow you can remove the Related Content Snippets. Inside config/application.rb, just after Bundler.require
ENV['RAILS_ADMIN_CONTENT_BUILDER_RELATED'] = 'false'Usage
For custom model, see: Customizing Model
Include in your controller
include RailsAdminContentBuilder::ContentBuilderHelpersExample
class PostsController < ApplicationController
include RailsAdminContentBuilder::ContentBuilderHelpers
def index
end
def show
end
end# Return all objects contents
@contents = all_contents_created
# Return especific object content
@content = find_content_created_by_slug('your-slug')
# Return content
@content = find_content_created_by_slug('your-slug')
@content.content_sanitizedIn your show content view
<article>
<h1><%= @content.title %></h1>
<p>
<%= @content.written_by %>
</p>
<p><%= @content.summary %></p>
<%= @content.content_sanitized %>
</article>You can see more stuff on the Wiki page!
Attributes and Methods
# Attributes
"title" : String
"written_by" : String
"date_publish" : DateTime
"content" : Text
"status" : Boolean
"slug" : String
# Methods
content_sanitized : Text
content_builder_images : ObjectDevelopment
After checking out the repo, run bin/setup to install dependencies. You can also run bin/console for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/thefalked/rails_admin_content_builder_rails_6. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
License
The gem is available as open source under the terms of the MIT License.
Code of Conduct
Everyone interacting in the RailsAdminContentBuilderRails6 project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
