Firedog is coming along quite nicely in my free time. This long weekend, I got some QT in, and through trial and error, and a little help from some friends, I integrated a forums application into my RoR app. First off, picking the right forums application to integrate is key, and after a lot of research, I decided to go with "Savage Beast", a plugin version of "Beast" which is known for it’s lightweight approach to forum building, with under 500 lines of code! I found a write up on Savage Beast here, and although it was slightly painful to get integrated, it was well worth the time spent. Especially since I already have an authentication mechanism (act as authenticated) that I am using, SB plays very nicely with my login/logout mechanism in place. Here is a step by step process for integrating SB into your RoR app that is already using Act As Authenticated. I hope it helps you get through the process quick and painlessly!!!
Preliminary Steps:
1) Read this blog entry from the SB guru.
2) If you don’t have a SVN already, download Tortoise
3) You’ll also need a console driven SVN, which can be downloaded here.
4) Use Tortoise to get the SB Demo from: http://svn.nnovation.ca/svn/savage_beast_demo/
Installation & Integration Instructions:
1) From your app’s root directory, install the SB plugin like this:
ruby script\plugin install http://svn.nnovation.ca/svn/savage_beast/trunk
2) Check out the SB Demo directory that you just downloaded.
3) Create a mysql database called savage_beast_demo
4) Open the demo’s config\database.yml file and alter the information to point to your new demo db.
3) From the root of the demo directory do a rake db:schema:load, this should create all the necessary tables.
3) Now we need to do some copies. As a windows weenie, I found it useful to have two Explorer windows up, so that I could keep an eye on my directory structure.
– In the Demo, navigate to the vendors\plugins directory, and copy all of those plugins into your App’s \vendors\plugins directory. The specific plugins are: browser_filters, engines, exception_notification, restful_authentication, savage_beast, white_list, and white_list_formatted_content.
– In the Demo\app\controller directory, copy sessions_controller.rb and users_controller.rb to your App’s controller directory.
– In the Demo\app\views directory, copy the folders sessions and users into your App’s views directory.
4) Now we need to copy those tables that were created into our App’s existing database. The tables to copy are: forums, moderatorships, monitorships, posts, and topics.
5) In addition to the table copies, we need to add 3 columns to our existing Users table, which was created when Act As Authenticated was integrated. The columns to add are: username varchar(255), posts_count int(11), and last_seen_at (datetime). Add these three columns under your primary id and before the login field.
6) Next we need to change the routes in our App’s config\routes.rb file. Open the Demo’s config\routes.rb file and copy these lines:
#get routes for beast
map.from_plugin :savage_beast
map.resources :users, :sessions
map.signup ‘/signup’, :controller => ‘users’, :action => ‘new’
map.login ‘/login’, :controller => ’sessions’, :action => ‘new’
map.logout ‘/logout’, :controller => ’sessions’, :action => ‘destroy’
map.connect ‘forum’, :controller => "forums", :action => "index"
7) Open your user.rb under your App’s model directory. Add this line near the top, after your class declaration:
include SavageBeast::UserInit
Time to BOUNCE the webserver!!!! Restart your App, I did a Ctrl-C where my local webserver was running and restarted it.
That should do it … I’m pretty sure that is everything!!! Now here’s the moment of truth …. you should be able to browse to: http://localhost:3000/forums
I found this thread on google groups really helpful, and definitely check out the demo and blog entry I linked to above! Now the challenge becomes making it look like part of your existing Rails App! I don’t have any tips for that one yet … Good-luck!!