Installing CommunityEngine on Rails 2.1
In a previous post, I talked about why we chose CommunityEngine. And due to the lack of documentation and several issues I had, I thought it would be useful to go through the installation steps and handling some issues.
Requirements
Required gems
- Rails 2.1.0
- rake 0.8.1
- rmagick
- hpricot
- htmlentities
- RedCloth
- haml
- aws-s3 (if using Amazon S3 for photos)
Notes for Windows users
- hpricot:
gem install hpricot ––source http://code.whytheluckystiff.net
- Download the latest version of rmagick-win32. At the time of writing, it is RMagick-2.6.0-ImageMagick-6.4.3-6-Q8.zip
- Extract the zipped file and run the installer
- Install the gem you downloaded:
- Restart Windows
gem install rmagick --local
Installation
- Create a new Rails app:
- Install the engines plugin:
- Put the community engine plugin into plugins directory:
- Create the databases:
- Rename public/index.html to index_backup.html
- Modify your environment.rb to look like the following:
RAILS_GEM_VERSION = '2.1.0' unless defined? RAILS_GEM_VERSION require File.join(File.dirname(__FILE__), '../vendor/plugins/engines/boot') Rails::Initializer.run do |config|
#resource_hacks required here to ensure routes like /:login_slug work config.plugins = [:engines, :community_engine, :white_list, :all] config.plugin_paths += ["#{RAILS_ROOT}/vendor/plugins/community_engine/engine_plugins"] ... end require "#{RAILS_ROOT}/vendor/plugins/community_engine/engine_config/boot.rb" - Modify all environment files ('development.rb', 'test.rb', and 'production.rb') by adding:
- Modify your routes.rb by adding this after any of your own existing routes, but before the default rails routes:
- Generate the community engine migrations:
- Migrate the database:
- Run your tests:
- Run CommunityEngine test:
- Start the server:
- Go to /signup to create a new user
- To set a user as admin:
- To activate the user, follow the activation link sent in the email (or appeared in the log after creating the user) or use this query:
- Enjoy!
rails community -d mysql
ruby script/plugin install git://github.com/lazyatom/engines.git
git clone --depth 1 git://github.com/bborn/communityengine.git vendor/plugins/community_engine
rake db:create:all
APP_URL = "http://localhost:3000"
map.from_plugin :community_engine
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
ruby script/generate plugin_migration
rake db:migrate
rake test
rake community_engine:test
ruby script/server
rake community_engine:make_admin email=user@foo.com
update users set activated_at = current_date where id = 1
Common Issues
- On Windows, if the app run without any css and the console shows a warning: Couldn't create the public file structure for plugin 'community_engine', modify engines.rb,line 147 to be:
base_target_dir = File.join(destination, File.dirname(source_files.first).gsub!(source, ""))
- If you get a warning: DEPRECATION WARNING: You're using the Ruby-based MySQL library that ships with Rails. This library will be REMOVED FROM RAILS 2.2, do this:
gem install mysql
Customization
- Do NOT edit any file of CommunityEngine plugin so you can replace it when updates are available in the future
- You can edit app/config/application.yml to override the default configuration defined in /vendor/plugins/community_engine/engine_config/application.yml
- Any views you create in your app directory will override those in /vendor/plugins/community_engine/app/views
- Creating an identically-named controller in your application's app/controllers directory, mixes your code with CommunityEngine's (your code takes precedence)
- To mix models code, you must require the CommunityEngine's model first (check this). Otherwise, your model would completely replace CommunityEngine's. For example: app/models/country.rb
require_dependency "#{RAILS_ROOT}/vendor/plugins/community_engine/app/models/country.rb" class Country "name") end end - For more info, check the readme file of CommunityEngine: /vendor/plugins/community_engine/README.markdown
Resources
- Home Page: http://www.communityengine.org/
- GitHub: http://github.com/bborn/communityengine/tree/master
- Documentation: http://www.communityengine.org/documentation.html
- Google Group: http://www.communityengine.org/group.html








Leave a Comment