Rails Blog Engine
Pre-beta release. Public APIs may change.
Add a blog to any Rails 3.1 site using
rails_blog_engine. First, add the
following line to your
bundle install rails generate rails_blog_engine:install rake db:migrate
Check the configuration in the newly-generated
config/initializers/rails_blog_engine.rb and tweak as necessary.
If you're using Devise, or another framework which defines
ActionController::Base, then all you need to do is add a
method to your user model:
class User # ...other stuff here... # Return true if the user is allowed to post to the blog, # moderate comments, etc. def blog_admin? # Your code here. end end
You should now be able to access your blog at
and start posting!
Philosophy and planned features
- ...be installable in under 5 minutes.
- ...be simple and easily hackable.
- ...be opinionated.
- ...be customized by overriding templates or forking the source, not by adding configuration options.
- ...be secure.
- ...follow all white-hat SEO best practices.
CoffeeScript, SCSS and other standard Rails 3.1 features are fair game, as are RSpec, HAML and CanCan.
The following features are on my wishlist:
- More generators to aid customization
- A basic editor: Auto-save, with preview and a "Publish" button
In other words, we want just enough features to make blogging pleasant, and nothing more.
What if I'm don't have
Add something like the following to
class :: def current_user # Check session, etc., here. end end
Please open an issue if you have any questions or problems.
Setting up titles and tags
To set up titles, add the two following
yield lines to the
<head> <title><%= yield(:title) %></title> <%= yield(:head) %> <!-- etc. --> </head>
Turning on the spam filter
To enable the spam filter, create an Akismet account at http://akismet.com/
and set the environment variables
you're deploying to Heroku, you can do this using:
heroku config:add RAKISMET_KEY="mykey" RAKISMET_URL="http://example.com/"
On your development machine, you can create a file named
.env in the root
directory of your project, and specify the variables as follows:
Then launch your application using the
foreman start command. This will
require adding the
foreman gem to your
Gemfile, and creating a
If you want to be able to display source code snippets with syntax
highlighting, you'll need to add the following line to your
gem 'pygments', :git => 'https://github.com/nathany/pygments-gem.git'
bundle install and restart your server. This will allow
you to include code snippets in your posts as follows:
<filter:code lang="ruby"> def hello puts "Hello!" end </filter:code>
You can also add your own filters. Documentation and generators should be available soon.