A blog implementation with WYSIWYG content editing, post scheduling, pagination and optional top level routes for each post category.
This is the 2.0 series of effective_posts.
This requires Twitter Bootstrap 4 and Rails 6+
Please check out Effective Posts 0.x for more information using this gem with Bootstrap 3.
Please first install the effective_datatables gem.
Please download and install Twitter Bootstrap4
Add to your Gemfile:
Run the bundle command to install it:
Then run the generator:
rails generate effective_posts:install
The generator will install an initializer which describes all configuration options and creates a database migration.
If you want to tweak the table name (to use something other than the default 'posts'), manually adjust both the configuration file and the migration now.
Then migrate the database:
Add the following helper to your application layout in the
<head>..</head> section. This works alongside effective_pages to include some publisher meta tags.
To create your first post, visit
/admin/posts and click
If you've defined more than one category in the
/app/config/initializers/effective_posts.rb initializer, you will be asked to assign this post a category. Otherwise the default category
posts will be assigned.
You can schedule a post to appear at a later date by setting the published_at value to a future date.
As well, if you're using the effective_roles gem, you will be able to configure permissions so that only permitted users may view this post.
config.use_category_routes is enabled in the
/app/config/initializers/effective_posts.rb initializer, each category you specify will automatically have a top level route. So posts created in the
:blog category will be available at
/blog and any posts made in that category will be available at
If disabled, all posts will be available at
/posts, with posts for a specific category available at
/posts?category=blog and the show routes will be
/posts/1-my-post-title regardless of category.
link_to_post_category(:blog) to display a link to the Blog page. The helper considers
config.use_category_routes and puts in the correct url.
The effective_bootstrap gem is used for pagination on all posts#index type screens.
The per_page for posts may be configured via the
All authorization checks are handled via the effective_resources gem found in the
The permissions you actually want to define are as follows (using CanCan):
can [:index, :show], Effective::Post if user.admin? can :manage, Effective::Post can :admin, :effective_posts end
There are some obvious additional features that have yet to be implemented:
- Some kind of helper for displaying a sidebar for the categories
- Post archives and date filtering
MIT License. Copyright Code and Effect Inc.
Run tests by:
- Fork it
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Add some feature')
- Push to the branch (
git push origin my-new-feature)
- Bonus points for test coverage
- Create new Pull Request