Savage Beast 2.0 - A Rails 2.0 Message Forum Plugin
I’ve been working the last couple days on creating a new version of the original Savage Beast plugin that is Rails 2.0 compliant and integrates the changes to the Beast source code that have been added over the last year. The result has been an interesting trek through the ins and outs of Rails plugin writing, that has given birth to a new version of the Savage Beast plugin, re-ported from scratch from the Beast trunk.
Installation
Currently, the following is necessary to use the Savage Beast plugin:
- The Savage Beast 2.0 plugin. Go to your application root directory and:
svn exporthttp://savage-beast-2.googlecode.com/svn/trunk/vendor/plugins/savage_beast - Most of the stuff you need to run Beast
- Redcloth:
gem install Redcloth - A bunch of plugins (white_list,
white_list_formatted_content,acts_as_list, gibberish, will_paginate, engines). The easiest way to install these en masse is just to copy the contents of savage_beast/tested_plugins to your standard Rails plugin directory (/vendor/plugins). If you already have versions of these plugins, you can just choose not to overwrite those versions
- For the engines plugin to work, add this line to the top of your environment.rb, right after the require of boot:
require File.join(File.dirname(__FILE__), ‘../vendor/plugins/engines/boot‘)
- Redcloth:
- Copy the migration in /vendor/plugins/savage_beast/db/migrate into your own migration directory (and run it)
- Implement in your User model the four methods in plugins/savage_beast/lib/savage_beast/user_init that are marked as
"#implement in your user model“ - Add the line “
map.from_plugin :savage_beast” to your routes.rb. Location shouldn’t matter unless you intend to override it. - Add the line “
include SavageBeast::UserInit” to your User model. Location shouldn’t matter unless you intend to override it. - Implement versions of the methods in SavageBeast::AuthenticationSystem (located in /plugins/savage_beast/lib) in your application controller if they aren’t already there (note: technically, I believe only “login_required” and “current_user” are necessary, the others give you more functionality). Helpful commenter Adam says that if you have the “helper :all” line in your application controller, be sure to add the “SavageBeast::AuthenticationSystem” line after that.
And off you go! When you visit your_site/forums something should happen. I’ve been creating new forums by visiting /forums/new. There’s probably a hidden admin view somewhere.
I’d like to remove some of these steps during the plugin install process with subsequent releases (is it possible to install a dependent plugin during your plugin install process?), but given that this is my first plugin project (and not a small one at that), I’m just trying to “get it done” before I “get it done beautifully.” I think DHH said somewhere that I should do that.
Implementing Your Own Views and Controllers
The engines plugin makes it eminently easy to mix in your own stuff as you see fit. Just create a new file in your /controllers or /views directories with the same name as the file you want to override in Savage Beast. If you just want to override a particular method in a controller, you can do that piecemeal if you just leave your XController empty except for the method you wanted to override.
If you’re integrating this into an existing site, I’d recommend you start by creating a forums layout page (/app/views/layouts/forums.html.erb). This will give you a taste of how easy it is to selectively override files from the plugin.
Demo
You can check out a (slightly-but-not-too-modified) version of Savage Beast online at Bonanzle. The differences between our version and the version checked into Subversion are 1) addition of topic tagging (users can tag topics to get them removed, etc) 2) recent post list shows posts in unique topics, rather than showing posts from the same topic repeatedly (there’s another blog on here about the SQL I used to do that) and 3) skinning. None of those changes feel intrinsic to what SB is “supposed to do,” which is why they aren’t checked in.
Differences from Savage Beast 1.0
The main difference is that this incorporates about a year’s worth of progress to the Beast source, and it actually takes that code a step further by being Rails 2.0.x compliant.
One thing Jodi seemed pretty excited about in the first Savage Beast was the ability to create forums off of models. Bonanzle doesn’t need that functionality, so I haven’t tested it, but I imagine it will probably work if you follow the steps that did it in the first Savage Beast.
TODO
Would be nice to have some help writing tests. Would also be great to figure out how to install this through the standard “ruby script/plugin install”.
Without Engines?
There are a couple means by which you can use this plugin without using the Engines plugin. I originally had intended to do this, suspecting that Engines would be a performance detriment. Turns out it’s not. But maybe you want to roll without Engines for some other reason.
The most dumb-easy way to get by without Engines would just be to copy the views, helpers, controllers, and models into your own project. Yes, it means having a lot more of all the above in your project, but it’s no worse than if you were coding the plugin from scratch yourself (actually, I’d argue it’s a lot better, since you didn’t have to do the work yourself :)).
Another way is to uncomment the code at the bottom of Savage Beast’s init.rb. Before I knew about the Engines plugin I created the code in there that simulates Engines without having Engines installed. The caveat is that you won’t get Engines’ ability to selectively override particular methods/views, and you need to copy all your helpers into the SB/lib directory, where they become global (yuck). If anyone out there has cycles to hone this Engines’-less approach, please email me and we can talk about getting those changes into the project.
Conclusion
Comments are most welcome. I’ll be checking in changes to the project as I find bugs and improvements in using it, but this is admittedly something I don’t have a lot of spare time to closely follow (see my other entries on the wonders of entrepreneurship). Hopefully others can contribute patches as they find time. If you like the plugin, feel free to stop by Agile Development and give it a rating so that others can find it in the future.
January 31st, 2008 at 10:03 am
Awesome! I have a site coming up in a few months that will need a forum system integrated with it. I was thinking of hacking Beast into a plugin so it really makes me happy to see someone has done the work for me.
I look forward to using this project and contributing any enhancements I make back.
January 31st, 2008 at 4:56 pm
Very cool! Thanks SO much for doing this.
February 3rd, 2008 at 10:02 am
I have a question about the Engines 2.0 requirement… I have an app that is not 2.0 compliant. Is there a way that I can still use this plugin while not being on the latest 2.0 version of rails? I am fairly new to rails so I am still learning how things are setup.
Thanks,
Andrew
February 4th, 2008 at 12:44 am
Hey
I’ve tried following your guide, but I keep getting the following error when I try to start the webserver. I have rails version 2.0.2 and the latest gem version. What am I missing?
Exiting
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:376:in `new_constants_in’: You have a nil object when you didn’t expect it! (NoMethodError)
You might have expected an instance of Array.
The error occurred while evaluating nil.empty? from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:202:in `load_file’
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:94:in `require_or_load’
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:248:in `load_missing_constant’
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:453:in `const_missing’
from /Users/rap/Documents/41concepts/Subversion root/simpledoc_old/vendor/plugins/savage-beast-2-read-only/init.rb:1:in `evaluate_init_rb’
from /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/rails/plugin.rb:79:in `evaluate_init_rb’
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings’
from /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/rails/plugin.rb:75:in `evaluate_init_rb’
… 35 levels…
from /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/server.rb:39
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require’
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require’
from script/server:3
February 4th, 2008 at 1:43 am
@Andrew: There is an older version of the Engines plugin (the current, stable release version) that you could use with a pre Rails 2.0 engine. However, this version of the Savage Beast plugin uses named routes that are specific to Rails 2.0, so chances are you’d have to do some refactoring to get things to work right. If you aren’t on Rails 2.0, your best bet might be to use the previous version of the Savage Beast 1.0 plugin that from Jodi’s blog: http://nnovation.ca/blog/ (it’s down as I type this, but it is usually up)
It has been tested with Rails versions prior to 2.0. I found that the documentation was somewhat spotty, but where things don’t work the way you would expect them, you can look at the instructions on installing SB 2.0 (the ones posted here), since the install process for both versions of SB are almost identical (SB 1.0 doesn’t use Gibberish, but that is the only significant difference that springs to mind)
February 4th, 2008 at 1:52 am
@Rasmus: Hmm… that is an error that I never saw during my development. What would be helpful would be to determine which of the plugins that SB is using that might be causing that error (since the error itself is not informative). A few ideas to try:
* If you move the Savage Beast plugin into a temp directory (out of vendor/plugins) do you still get the error?
* If you move the engines plugin into a temp directory (out of vendor/plugins) do you still get the error?
* Did you add the line that the Engines web page mentions into your environment file?
If you can narrow down the plugin and/or line that is specifically causing that error (and post what you find here), I could try to provide further assistance. I’d be interested to hear if others have gotten it working fine or had similar problems?
February 4th, 2008 at 7:08 am
I think, that I have this same problem. I have added this line with Engines boot file. When I remove SB plugin from vendor/plugins everythin looks all right. When I remove Engines plugins I still have this error.
February 4th, 2008 at 9:45 pm
@Galdrian: Alright, I’ve found one problem: It looks like the Google Code name of the plugin (savage-beast-2-read-only) is interpreted to be the name of the plugin itself, which makes the routing for the plugin unhappy. It looks like the plugin needs to reside in a directory called “savage_beast” inside the /vendor/plugins folder. I’ve updated the instructions. I’ll see if I can get ahold of you or Rasmus directly to see if this resolves your problem or further steps are necessary…
February 5th, 2008 at 4:52 am
Yeah, success..
The error message gave me a nil exception, but it was difficult to track down. Your email saved me. It was indeed the naming of the plugin folder that caused this.
Your tutorial says that the plugin should be put in a folder called “savage-beast-2-read-only”. When this was renamed to “savage_beast” it worked (at least in the dummy project I set up to play with this that doesn’t contain more than a single “User” class).
I haven’t been through all the functionality, but now I can see the forum.
Thanx for all you help (and the plugin).
February 9th, 2008 at 3:19 pm
Quick question, I’ve got savage_beast installed and sort of running, im having troubles though when i go to /forums I get the error uninitialized constant ForumsController, I’ve been playing around with it for an hour or so but can’t figure it out, any idea why this is happening?
February 10th, 2008 at 6:38 pm
@Justin: Still having the error? Paste your call stack and I’ll see if it makes any sense. Sounds like a potential error with the Engines installation (which should find the ForumsController in the SB /views directory)
February 11th, 2008 at 10:47 am
Bill, Yes i got that part working now it was a mistake I made when setting it all up, I am onto another problem now though. I’m setting up the forums inside an existing rails app and i can get to /forums just fine, but then I start running into problems. whether or not I’m logged in, when i head to /forums/new I get redirected to my login page, So I guess I don’t understand why login_required in my main app works, but inside the forums it always assumes I’m logged out. Any ideas?
February 11th, 2008 at 11:54 am
EDIT: So i know what the problem is, just not how to fix it yet. It has to do with my authenticatedsystem (restful authentication). When I restart mongrel and hit refresh on /forums it loads fine, then if i hit refresh again the error comes up. It seems like it’s unloading my authenticatedsystem after 1 page refresh for some reason. I tried adding ‘include AuthenticatedSystem’ inside savage_beast/app/controller/application.rb but still get the same error.
February 11th, 2008 at 3:30 pm
UPDATE: okay I seem to have figured out the problem, you need to add ‘unloadable’ to the forum controller because of the way it loads the plugins directory. So far everything seems to work okay with this fix
February 11th, 2008 at 6:35 pm
Back with another error. Most of the stuff is working okay, Im having trouble with display_name in places, but i just change it from user.display_name to user.login and it works fine, the problem I have now is when I try to create a new post on a forum i get “User expected, got User”, and it’s happening in the assign_protected call, but I don’t understand why it got ‘user’ and gave me an error when it was looking for ‘user’
February 11th, 2008 at 6:49 pm
UPDATE: 1st, sorry for all the posts, I should wait to comment till I test a little more. The problem was similar to before with the ‘unloadable’ line, this time I had to add it to all the models in the beast app and it works fine. cheers.
February 11th, 2008 at 7:16 pm
@Justin: It’s funny, I got that “User expected, got User” error myself when I first started working with SB. I concluded it was the Engines plugin, because after I uninstalled Engines, I stopped getting it. But when I reinstalled Engines a few days later I couldn’t get it to happen again. The weird thing was that I got that error repeatedly the first day I was playing with SB, and have not been able to get it since, using it for more than a month now. It’s wily and mysterious bug that vanished without my having done anything remarkable to fix it. But it sounds like you have found one specific approach to make it go away, which is good.
February 12th, 2008 at 12:08 pm
@Justin: If you don’t mind my asking what was the issue with the uninitialized constant ForumController error? I’m getting the same error.
February 12th, 2008 at 1:30 pm
Nevermind, I figured out what was going on with the uninitialized constant ForumsController error.
February 13th, 2008 at 12:51 am
About uninitialized ForumsController - I’ve also faced this issue, and it was because I did not properly install engines plugin. It needs the following line to be added to environment.rb (see its readme file for details):
require File.join(File.dirname(__FILE__), ‘../vendor/plugins/engines/boot’)
February 13th, 2008 at 1:01 am
Now I have another problem - implementating auth system methods doesn’t work for me.
SavageBeast::AuthenticationSystem methods are being called instead of ones of ApplicationController.
For now I will add implementation directly to internals of SB, but I’d wanted to know what is the better way or how to get implementation working from my application code?
February 13th, 2008 at 1:35 am
In addition to my last post - I’ve put implementation into AuthenticationSystem itself, and it seems to workm but sometimes current_user method is being called onto ApplicationController and that produces error:
“A copy of ApplicationController has been removed from the module tree but is still active!”
I’ve googled on this, found some Trac reports and other notes, but found no solution. Connection between plugin and applicaton seems to be quite tricky…
February 13th, 2008 at 7:25 am
Sorry for posting so mush messages, but I got SB working almost good enough - I have to do some tweaking yet.
(But I had to force application.rb and user.rb loading in environment.rb, so they are not reloadable now)
And there are some more issues:
1. Forums can be created (via /forums/new/ even when user is not an admin).
That is why SavageBeast::AuthenticationSystem#admin? is used as before_filter, but when it is implemented like in example code it doesn’t do any redirect or something like. Correct before_filter must perform redirect instead of just returning boolean value.
2. User.logged_in? seems to never been called
3. In SB there is missing application.js, containing javascript for forum popup forms.
I’ve got it from original Beast and it works ok, while without it it is not possible to post a reply
February 13th, 2008 at 1:29 pm
@Bill: Hey I’ve been messing with the forums the past couple days and been havin fun, though it’s my first experience with textile so it took me a while to figure some formatting stuff out. Couple Q’s for you. first off I know the way it formats the post to textile uses RedCloth, I’m wondering how how hard it would be to make it so I can have traditional img links link [IMG]link[/IMG] . I assume it’d be re-writing part of redcloth. Next question is, do you have a way to quote text from another users post? I sorta looked through and didn’t see anything, and it wouldn’t be too hard to write up some code to do that, I just don’t wanna do it if it’s already been done. Cheers.
February 14th, 2008 at 1:43 am
@Kamaitati: In regards to the authenticationSystem modules, it is the Engines plugin that usually takes care of locating the local versions of those functions. If you look in your console output, you can see that every time a helper gets called, Engines goes through your list and finds where it should grab the helper from. For me, it always chooses the ApplicationHelper versions of those methods, but I’m not entirely sure how it chooses the order it will search in. Perhaps you could look at your console output and see if it is finding the helper methods in your Application controller, but ignoring them for some reason?
As far as your other points, you are right on all three counts. I have checked in a new version of SB that addresses all of these issues. Thank you for your feedback.
February 14th, 2008 at 1:57 am
@Justin: Those are two good questions. So good, in fact, that I don’t know the answer to either.
For our site, I’m keeping the forums pretty dirt simple, not teaching users about formatting (yet) and not letting them explicitly quote past posts, though you are correct that it theoretically wouldn’t be difficult. Actually, I think the trickiest part of quoting past posts is that you’d have to declare which post you are quoting. The way Beast is setup by default, you respond to a topic thread, not to a particular message in that thread, so you would need to update the UI such that you were responding to a specific message. The UI sounds more difficult than the programming to me.
February 14th, 2008 at 9:35 am
@Bill, Thanks for your answer. I’m gonna make up a quote message function, won’t be hard since the posts are already labeled post-*id* Just need some javascript to grab the value of the post throw it into some block quote. I’ll post the code when I get it written up in case someone else wants to use it. AS for the [img][/img] I went into redcloth.rb and found where it renders images, and replaced the !’s with [img][/img], but the problem (i now believe) has to do something with white_list, because if you try to add [img] tag to your post it just gets stripped out, so it works in redcloth now, just white_list is killing the tags D: I’ll post updates later
February 15th, 2008 at 3:51 pm
Just for reference you may need the will_paginate plugin installed too. I did at least. (http://rock.errtheblog.com/will_paginate).
February 16th, 2008 at 3:04 pm
@James: Thanks for uncovering one of the dependencies I didn’t even know about (since I already had that installed). I’ve updated the instructions.
February 16th, 2008 at 3:05 pm
I got only as far as point 3. and then I realized I cannot generate any migrations or run them. It seems the savage_beast plugin doesn’t like ActiveRecord and breaks things. After installation of savege_neast I’m getting the following error when I try to generate a migration:
./script/generate migration moj_test2
/usr/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:376:in `new_constants_in’: You have a nil object when you didn’t expect it! (NoMethodError)
You might have expected an instance of Array.
The error occurred while evaluating nil.empty? from /usr/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:202:in `load_file’
from /usr/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:94:in `require_or_load’
from /usr/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:248:in `load_missing_constant’
from /usr/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:452:in `const_missing’
from /home/kopszak/PRACE/METARAILS/mc-temp/okle-b/vendor/plugins/savage-beast/init.rb:1:in `load_plugin’
from /usr/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/initializer.rb:407:in `load_plugin’
from /usr/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings’
from /usr/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/initializer.rb:407:in `load_plugin’
… 9 levels…
from /usr/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/commands/generate.rb:1
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require’
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require’
from ./script/generate:3
February 18th, 2008 at 1:27 am
@Piotr: You don’t need to generate the migrations. The migration file you need is already provided for you in the savage_beast/db/migrate directory. There is one migration file there. If you copy that to your db/migrate directory and rename it to be your newest migration, all should be well.
March 4th, 2008 at 2:27 pm
@Kamaitati and Bill:
I figured out the problem with AuthenticatedSystem methods not being called and disappearing. I had placed the call to include AuthenticatedSystem in application.rb right before the default “helper :all # include all helpers, all the time” line. Placing it just *after* that line fixed everything. I’m guessing that Engines was causing the SavageBeast::AuthenticationSystem to be included over the AuthenticatedSystem because of the inclusion order.
March 5th, 2008 at 1:01 pm
I’ve put together my complete instructions for getting running here: http://localbiz404.blogspot.com/2008/03/integrate-forum-with-rails-site.html
Note: I kept having more issues with unloaded modules, so I decided to just get around it by running in production mode.
Awsome work on the plugin, and thanks for sharing it with us!
March 6th, 2008 at 2:56 am
Thanks Adam. Your post brings up an interesting idea — perhaps I should just include versions of the necessary plugins (as they’ve been tested and working with my version of SB) along with the SB install. This would mean that (1) we aren’t as beholden to the trunk versions of these plugins not changing and (2) it is less install steps without all those plugin installs. Of course, for those that already have versions of the plugins they wanted to keep, they could just not use SB’s versions of those plugins.
I’ll try to find some time to do that in the next week. I’m also still extremely interested in being able to install SB 2 through a standard ruby script/plugin install, hopefully my new “Advanced Rails” book can illuminate how to do this in enough simplicity that I can squeeze it in soon.
March 10th, 2008 at 1:35 pm
I had the problems with unloaded models as well - the display_name problem, etc. Some of my error pages actually complained that the stack was too big; instead of method_missing it was trying to call method_missing_with_paginate from will_paginate, and that just led to all kinds of strife.
I finally found a newsgroup posting with the fix - it took care of all the problems in one shot:
http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/f84896c2955579af?fwc=1
Thanks for sharing the beast!
March 11th, 2008 at 12:14 am
@Peter@ Great tip for a problem that I think many others will appreciate. I’ve updated the install instructions so that people will be able to find this information.
March 12th, 2008 at 4:33 pm
Alright, I added the Google Groups fix pointed out by Peter into the source, so hopefully the engines unloading modules problem should be no more.
March 14th, 2008 at 2:12 pm
I was having issues with a users_path variable not being found. Adding map.resources :users to routes.rb fixed the issue.
Im brand-spanking new to ror, so this may be trivial for some.
March 18th, 2008 at 2:46 pm
Hey, where’s the default title variable located?
March 18th, 2008 at 6:17 pm
It’s a gibberish thing. All the strings are stored in a YML file. I don’t remember which one (en.yml?). I’d recommend that you A) Look at where gibberish gets its strings from or B) do a find all in your project for whatever the text is that ends up being used in the title variable (when you see it in the view)
March 19th, 2008 at 6:02 am
Hi Bill, thanks for that–
I’m now getting this error, scattered about my site:
NoMethodError in Topics#new
Showing vendor/plugins/savage_beast/app/views/topics/new.html.erb where line #8 raised:
undefined method `display_name’ for nil:NilClass
Extracted source (around line #8):
5:
6:
7:
8:
9:
10:
11:
I’ve implemented display_name as a single line in my User model. It is “self.login.” Current_user is set in my application controller as session[:user] — when I put a debugger statement in the respective controllers (i.e., in this case it would be topic), current_user.display_name returns correctly. However, the debugger statement placed in a view shows me that both current_user and display_name and logged_in? etc are all nil, thus not accessible from the view. How may I approach this?
Very much appreciated.
March 19th, 2008 at 12:32 pm
well I gave up on the display_name problem. Cycling through a million different files looking for a line of code that may or may not be there that you may or may not notice whose form you’re unsure of is like searching for a pin in a haystack. Andrew’s tutorial didn’t work integration-wise so I’m testing it verbatim from scratch.
March 19th, 2008 at 12:52 pm
By Andrew I meant Adam. Thanks Adam. Creating a project from scratch and following your instructions verbatim results in a working Savage Beast. Thanks Savage Beast.
March 26th, 2008 at 9:18 pm
Sorry for posting such a basic request, but I am coming from java land and need a bit of help here. Could someone post the basics of what should be in user.rb file to get things moving here?
March 29th, 2008 at 9:00 pm
almost have this working.
on one computer, i am getting the following error:
uninitialized constant Rails::Plugin::RedCloth
on another, i am getting:
NoMethodError in Forums#show
Showing vendor/plugins/savage_beast/app/views/forums/show.html.erb where line #33 raised:
undefined method `has_key?’ for :rss:Symbol
which comes from
anyone have any idea how to get past these errors
March 30th, 2008 at 12:17 am
how do you force application.rb and user.rb to load in env.rb??
March 31st, 2008 at 9:17 am
savage beast 2 somehow make my rails messages dutch!!!
how do i fix that?
March 31st, 2008 at 10:19 am
See the docs for the gibberish plugin, which is what SB2 uses for localization.
April 2nd, 2008 at 9:36 am
Hi Bill,
sorry to bother you again, but I have one other problem
I did some modification to my installment of savage beast 2 but I am getting the following error whenever I edit and create forum, topic, or post
NoMethodError (undefined method `controller_name’ for nil:NilClass):
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/caching.rb:655:in `callback’
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/caching.rb:637:in `after’
after some investigation, for some reason the *_path are not returning restful url.
for example,
/forums/1/topics/1/posts/11/edit?page=1
now becomes
/posts/11/edit?forum_id=1&topic_id=1
and i think this is why my edit and create doesn’t work anymore.
Do you have any idea why this is happening and how to fix it?
Thanks in advance!
April 2nd, 2008 at 11:11 am
Hi,
I want to use savage beast for my website . But I am on rails 1.2 and I am facing compatibility issues with savage beast. Do we have any workaround to get it working?
Thanks,
~S
April 2nd, 2008 at 1:05 pm
nevermind…i screwed up something…
great plugin btw..
April 3rd, 2008 at 11:45 am
@Sonia@: The original Savage Beast is the answer for Rails 1.x’ers: http://nnovation.ca/blog/
April 7th, 2008 at 2:47 pm
Hi Bill,
Just want to report a bug,
When I try to delete topic as admin, I get
NoMethodError (undefined method `update_posts_count’ for #):
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/attribute_methods.rb:205:in `method_missing’
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/core_ext/symbol.rb:11:in `__send__’
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/core_ext/symbol.rb:11:in `to_proc’
/vendor/plugins/savage_beast/app/models/topic.rb:85:in `each’
/vendor/plugins/savage_beast/app/models/topic.rb:85:in `update_forum_counter_cache’
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/callbacks.rb:307:in `send’
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/callbacks.rb:307:in `callback’
April 14th, 2008 at 4:23 pm
Hi,
Thanks for this plugin.
I am integrating beast into an existing site.
When I perform /forums, I get the following error
undefined method fond_ordered for …
My trace on the server shows me that engine is not able to loacate forums_controller, forums_helper
I am able to see the forum/new page but run into problems when I try to create a new pose.
Is my error due to some missing configuration to load beast plugin corrrectly.
Thanks,
-Ram
April 14th, 2008 at 4:24 pm
“undefined method fond_ordered for …”
should read
“undefined method find_ordered for …”
I see that this method is defined in the SB plugin.
April 15th, 2008 at 6:56 am
We are using the will_paginate gem on a project that has Savage Beast installed. (This has recently been updated from a plugin to a gem.)
On 04/07/08, the developer changed the “page_count” method name to “total_pages” that is hanging off the model. Savage Beast uses “page_count” which was “giving me a undefined method page_count” error in quite a few places. I had to do a find/replace to change these all to total_pages and all appears to be working now.
April 17th, 2008 at 1:23 am
Hi,
I looking for oryginal Savage Beast for rails 1.x, but http://nnovation.ca/blog/ seems to be not runing.
Can i download it from somewhere?
Krzysiek
April 18th, 2008 at 3:15 am
@Ryan@: Thanks for the report. I’ll look into that next time I’m updating the plugin. Let me know if you fix it yourself and could give me specific code to add to the project.
@Ram@: I think that is a default Rails route? Never seen that particular error. Maybe someone else who has will chime in.
@Jim@: Thanks for the tip. I’m sure others using the gem version of will_paginate will appreciate this.
@Krzysztof@: I don’t have the original SB, but I know that nnovation.ca/blog has a history of being up and down (was down for a couple days when I first tried to grab it). Keep at it, email Jodi Showers if you can find his address. And maybe bug him to put the project on Google or RubyForge…
April 20th, 2008 at 6:20 pm
hi bill,
I think the problem is that it’s trying to update the post count of all the user in that topic, but the User model doesn’t have that function update_posts_count anymore. I don’t need savage beast to track user post count, so I simply commented out that line
#@voices.each &:update_posts_count if @voices
and it works perfectly now
April 21st, 2008 at 3:35 pm
@ryan@: Thanks buddy! I’ve updated the source with your change.
April 28th, 2008 at 12:18 pm
I also was experiencing the oddness of seeing Dutch languge activerecord errors… it was because of an incomplete removal of the GetText gem translations previously being done by savage_beast. Nothing to do with Gibberish plugin, as a previous response had claimed.
Commenting these two lines out from the init.rb makes everything good again:
# require ‘gettext/rails’
# GetText.locale = “nl” # Change this to your preference language
Thanks for working on getting savage_beast up to speed on Rails 2.0!
April 29th, 2008 at 11:44 am
Hi,
where should i set value of variables users_path and forums_paht, any maybe other?
thank you in advance
Krzysiek
June 12th, 2008 at 8:04 am
Is there a Google Groups available for this plugin? It would act better as a place for support.
My question is, how do I delete a forum once created?
I see the controller function is there, but it doesn’t seem to be linked from anywhere in views.
June 12th, 2008 at 9:11 am
Zac, I believe there is a Google Groups-like thing in the Google Code project, but I hardly ever visit it. Others might.
In regards to your question, I know that an edit/delete link pop up when you mouse over a topic, but I believe that the Beast thinking is that Forums are generally static, whereas topics within Forums come and go (e.g., are created and deleted frequently). Thus, whatever link there might be to delete a forum is probably well hidden within the standard Beast views.
But I don’t know for sure, because in practice, and certainly with us, most apps overwrite the standard Beast views before they get to production, so once those views have been replaced by your own (which is as easy as just creating the overriding view partials in your app/views/* directory), then the links that are provided to add/edit/delete are totally up to you.
June 23rd, 2008 at 6:26 am
Hi do you have a solution to prevent simple users from creating forums or editing/deleting other user’s posts?
Thanks.
July 3rd, 2008 at 11:04 am
move from google groups to github? can spur more open developers to join in
July 5th, 2008 at 9:29 am
@tito: Access to edit or delete posts is dictated by the admin? method in SB, as I recall (without the code in front of me right now). If not admin, there’s some other similar method that dictates that. It was one of those things that “Just worked” for me, so hopefully it will with you too.
@wilson: A good idea. I’ll take another look in the next few days to see if Git for Windows has reached the point of being decent yet, and if so, hopefully move over SB in the near future.
July 18th, 2008 at 3:24 pm
We just spent some time making savage beast compatible with Rails 2.1. Since we couldn’t find any information out there while we were sorting through the errors, I’ll post our fixes here in case anyone else encounters similar issues.
1. All the named routes in savage_beast started throwing exceptions. We found that an update to RESTful routing started to automatically prefix nested resources. SB doesn’t follow this convention. To fix, we had to pass an extra “:name_prefix => nil” to our nested routes in SB’s routes.rb, like so:
map.resources :forums do |forum|
forum.resources :topics, :name_prefix => nil
forum.resources :topics do |topic|
topic.resources :posts, :name_prefix => nil
topic.resource :monitorship, :controller => :monitorships, :name_prefix => nil
end
end
2. We’ve been using the will_paginate gem and of course, this also caused incompatibilities with SB, which was depending on an older version of will_paginate. To fix, we had to change all instances of @post_pages or @topic_pages to @posts and @topics, respectively. Also, the method page_count had to be replaced with the new total_pages. Lastly, the method “pagination_links” had to be changed to “will_paginate”, with the appropriate collection as the param.
3. Voices. I love the “voices” feature of SB, but that also stopped working. Two easy changes here: in the views, just change @voices to @topic.voices. When SB needs to update the forum counter cache, it tries to call a method “update_posts_count” on a “voice”. For us, that’s a user, so I added this to our user.rb:
def update_posts_count
self.posts_count = Post.find(:all, :conditions => {:user_id => self.id}).size
self.save
end
4. Finally, we ran into a strange 502 Bad Gateway issue when deployed into our nginx/mongrel environment. It only happened with IE when creating a new post. Turns out the Post#create redirect passes an :anchor param, which generates an HTML anchor (#) symbol in the URL. This was causing problems with nginx in IE only. The simple fix was to simply remove the :anchor param, since all it was doing was scrolling the user to the new post.
And now we’re rolling with SB on Rails 2.1…
July 18th, 2008 at 4:30 pm
Chris — you’re a saint!
We’ll probably be moving to 2.1 in the next couple months, I’ll definitely refer to your guide when we make the jump, and check in the changes at that time.
Do you think these changes will be backward compatible, such that we could update the main code base to work with Rails 2.0.x and 2.1?
July 19th, 2008 at 3:24 am
Bill - I don’t see anything that would break with Rails 2.0.x The :name_prefix param should just be ignored in older versions of RESTful routing. Good luck!
July 22nd, 2008 at 1:51 am
i get the following error when i tried to do the migration.I am using rails 2.1.Can you please provide me the steps for getting out of this problem. I am struck here.I googled but it was of no use
undefined method initialize_schema_information’ for module `ActiveRecord::ConnectionAdapters::SchemaStatements’
i commented the following line in migrations.rb and was able to work to some extent.But i am facing problems in will paginate plugin’s init. can you provide me a permanent solution?
def self.included(base) # :nodoc:
# base.class_eval { alias_method_chain :initialize_schema_information, :engine_additions }
end
July 23rd, 2008 at 11:10 am
@prabha: I’m not on Rails 2.1 yet, but hopefully Chris or another user that is can speak to your problem. Bonanzle probably won’t be moving to 2.1 for another month or two. There’s a lot to be done.
If anyone who gets SB working with Rails 2.1 and would like commit access to the SB repository, I’m game for that, as long as it remains 2.0.x compatible.
July 23rd, 2008 at 1:35 pm
prabha - haven’t seen that before. But if you’re having issues with the will_paginate plugin, maybe the easiest thing to do is to upgrade to the will_paginate gem (sudo gem install will_paginate), and then follow the instructions in my earlier post.
bill - I may be adventurous enough to give it a shot. But I’m working from Beijing at the moment and don’t have too much spare time. Have you also considered hosting it on github? That may open up contributions a little.
July 23rd, 2008 at 7:57 pm
I just installed to a Rails 2.1 project. The migration was not an issue. No idea why @prabha would be having issues with that.
However, there was an issue with the “will_paginate” plugin. It was given a “stack level too deep” error when accessing the Topic view.
This issue was an issue with an old “will_paginate” and Rails 2.1.
http://err.lighthouseapp.com/projects/466/tickets/223
Updating to the latest gem and referencing the gem via the environment.rb file corrected the issue.
Unfortunately, I am now getting a “undefined method `page_count’” error.
July 23rd, 2008 at 9:07 pm
So it turns out I commented on this “page_count” error on April 15th. I thought it looked familiar.
To correct the issue, do a global find and replace of “page_count” to “total_pages”.
July 29th, 2008 at 8:52 am
@prabha: I have had the same problem today with rails 2.1, and you can solve it updating the engines plugin.
Instead of use the version in tested_plugin, download the last version.
July 30th, 2008 at 12:14 pm
Hey, I was wondering if anybody had a nice method or direction for overloading the posts class. I am using a blog and I want to use this for a forum plugin, but since savage beast and my blog use the posts class it causes issues. Does anybody have some suggestion?
July 31st, 2008 at 3:59 am
thanks lot Diego
August 7th, 2008 at 12:06 am
Hi,
I am getting the following error when am trying to svn export :
Error: REPORT request failed on ‘/svn/!svn/bc/9/trunk/vendor/plugins/savage_beast’
Error: ‘/svn/!svn/bc/9/trunk/vendor/plugins/savage_beast’ path not found
Could someone please suggest any solution or alternate way to get the plugin installed?
Thanks,
Disha.
August 7th, 2008 at 11:38 pm
I get a bunch of information added to my server after implementing forums using savage beast.Is there a way to cut that off? Can anybody help me?
August 9th, 2008 at 12:52 am
@Disha: What address are you trying the export? The one you’re listing there appears to be different than the http://savage-beast-2.googlecode.com/svn/trunk/ address at which the plugin exists.
@Prabha: You’re probably observing the output of the Engines plugin. On my install, I commented out most of the debug info given by the Engines plugin by going into the Engines plugin and commenting the line that was doing most of the blabbering (don’t remember which one it was anymore, but do a find all for whatever the text you’re seeing is).
August 9th, 2008 at 7:00 pm
Hey Bill - thanks for working on this plugin, ever since I first discovered Beast I’ve wanted to add it to an existing site, rather than having to create a new one…
I’m trying to use SB without Engines. You mention above that the easiest way would be to just copy the controllers/helpers/models/views into my own app, which I’ve done. Of course I immediately get some errors about no `admin?` method in forums_controller.rb The only place I see a non-model `admin?` method is in /lib/savage_east/authentication_system.rb There’s a comment at the top that says “override in your app controller” Override what? Should I copy all of those methods into application_controller.rb and then uncomment the bodies of the methods?
/lib/savage_beast/user_init.rb mentions implementing a few of the methods in my own user model (there are specific comments above `admin?` and `display_name`) and then everything below the `ClassMethods` module…if those are really class methods, should I actually copy them into the model with `self.` in front? Should I just copy everything, ignoring the `base.extend` and module definitions, of course.
Is there anything in /init.rb that I need to worry about?
Should I just shut up and use Engines like you intended?
August 10th, 2008 at 5:30 pm
@Rob: Heh, Engines isn’t exactly the daintiest plugin… at all… so I can understand the initial aversion to it, I certainly felt the same way, though I have since come to love it and use it for many other subsystems in my app (like our feedback and blog systems). But that isn’t really your question.
The “override in your app controller” means that, for each method at which you see that, you should create a method in your application controller that implements that functionality in a way consistent with how you define an “admin” (or whatever) user in your application.
Same with the user model. Since everyone might have a different way that they define the display_name for the user, it’s intended that your user model will implement all of the methods that SB says “implement in your own X.”
You shouldn’t have to worry about anything in init.rb, you’ll just need to make sure that you get all the routes into your routes.rb from the SB routes.
Hope that clarifies things a bit.
August 10th, 2008 at 11:31 pm
Thanks Bill
August 14th, 2008 at 2:53 pm
Hi Bill,
just wanted to ask if there is an easier way to style the forums without having to explicitly state in the controller that the layout to be used should be forums.rhtml.erb? I tried overriding the file as you said(by creatign a forums.rhtml.erb file in my layouts folder) and it worked fine…for the index. when i clicked on a post, it proceeded to use the application default layout.
Also, what about shared partials? I am planning to clean up my application or forum layout by dividing the sections into partials, but when i tried making a /shared/ folder for my partials in my app/views/layout folder, savage beast still keeps looking for those shared partials in its own views/layout folder.
thanks!
August 14th, 2008 at 4:29 pm
my friend gave me a good suggestion for the shared partial problem: just make an empty “shared” folder in savage_beast\app\views and if you are using the engines plugin, it will “overwrite” the shared folder with what you have in your app’s shared folder.
the only remaining problem for me is that the topics controller and the post controller is loading the application.rhtml.erb instead of the forum controller. is this really the case by default?(and thus i have to override those controllers to force them to load the forums layout?) thanks again in advance!
August 26th, 2008 at 2:48 pm
…just found out about savage beast.
fyi, if you’re getting this error message reported by @prabha on rails 2.1:
undefined method initialize_schema_information’ for module `ActiveRecord::ConnectionAdapters::SchemaStatements’
you can fix this by not using the engines plugin in the tested_plugins and instead getting the latest:
cd vendor/plugins
git clone git://github.com/lazyatom/engines.git
git checkout 2.1.0
cheers,
tom
August 27th, 2008 at 3:29 am
how use it in rails 2.1.0
September 18th, 2008 at 7:34 am
How exactly do you do step 4. Can someone please explain how to do this as well as an example?
September 26th, 2008 at 12:11 pm
Thanks so much for the great work. Just got it up and running in Rails 2.1.1 and mostly just had trouble with plugins, like “page_count” method name to “total_pages” for will_paginate. Your savage_beast plugin will show up in the wild at the LegalTorrents.com website in a few days.
I’m curious if the plugin will track altered_beast. True to technoweenie’s form, beast-2.0 is not called beast-2.0, but altered_beast: http://github.com/courtenay/altered_beast/tree/master
It would be pretty cool if savage_beast was an actual fork at github of altered_beast…
Thanks again for making savage best 2.0…
September 26th, 2008 at 12:27 pm
*Austin Web Developer, this is one possible way to do step 4:
class AddAdminToUsers false
end
def self.down
remove_column :users, :admin
end
end
——— user.rb —————-
def display_name
if current_user.login.blank?
current_user.name
else
current_user.login
end
end
def self.currently_online
User.find(:all, :conditions => [”last_seen_at > ?”, Time.now.utc-5.minutes])
end
def self.build_search_conditions(query)
query && [’LOWER(login) LIKE :q’, {:q => “%#{query}%”}]
query
end
September 26th, 2008 at 12:31 pm
*Austin Web Developer, this is one possible way to do step 4:
**repost, the last code got munched some how…lets try again:
{{{
class AddAdminToUsers false
end
def self.down
remove_column :users, :admin
end
end
——— user.rb —————-
def display_name
if current_user.login.blank?
current_user.name
else
current_user.login
end
end
def self.currently_online
User.find(:all, :conditions => [”last_seen_at > ?”, Time.now.utc-5.minutes])
end
def self.build_search_conditions(query)
query && [’LOWER(login) LIKE :q’, {:q => “%#{query}%”}]
end
}}}
October 9th, 2008 at 3:06 pm
My bad:
1) The migration above is still being eaten cause I don’t know how to post code to wordpress. But it simply adds an example admin boolean to users.
2) I misspoke, altered_beast isn’t the official fork of beast…I just got confused as I saw technoweenie’s commits on altered_beast. I did notice though altered_beast has movement and technoweenie also has his own fork of altered_beast on github…
ok, back to adding Rick’s viking fork to savage_beast for Spam filtering: http://github.com/technoweenie/viking/tree/master/lib
October 17th, 2008 at 12:18 pm
so I just copied the following and placed it in my user.rb
def display_name
if current_user.login.blank?
current_user.name
else
current_user.login
end
end
def self.currently_online
User.find(:all, :conditions => [”last_seen_at > ?”, Time.now.utc-5.minutes])
end
def self.build_search_conditions(query)
query && [’LOWER(login) LIKE :q’, {:q => “%#{query}%”}]
end
is that all I need to do? I’ll keep moving forward to see if this works.
October 17th, 2008 at 12:30 pm
I am trying to add this to substruct and I pasted the map.from_plugin :savage_beast and I get this error:
/Users/nathan/Sites/projects/ror/1stmarine/vendor/plugins/savage_beast/init.rb:30:in `from_plugin’: undefined local variable or method `map’ for # (NameError)
October 23rd, 2008 at 4:57 am
Hi
I have problem with authenticated system.
I have User model and i have already added authenticated(acts_as_authenticated)plugin for my application.
included AuthenticatedSystem in my application controller.
now, I added savage beast, its working nice.
But if i clicked on Create new Forum,its goes to login page ,
another one is users_path undefined method, and current_user is nil
how to fix those problems with authenticated system.
i didn’t do any changes in savage beast application controller and my application controller
only i added 4 methods to user Model.
how to connect my application with forum.
please help me.
thanks.
October 24th, 2008 at 4:04 am
Hi,
I am facing new issues with above issues
i cant give a reply for the topic.
if i click on Reply to Topic link,it is not going any where.
how to give reply for the topic?
thanks,
ravi.
October 26th, 2008 at 8:26 pm
I encountered problems with engines when my rails version is on freeze. Could someone enlighten me about this issue? The engines is fine though when rails is not freeze.
October 27th, 2008 at 1:29 am
Hey Ravi,
I think the reply uses Javascript and RJS… tho I haven’t heard any specific issues with it before. Be sure to post it when you figure out what your problem is.
October 29th, 2008 at 10:30 am
Is there a live sample of Savage Beast 2.0 anywhere?
October 30th, 2008 at 8:19 am
Hey Doug,
Good question. I’ve added a “demo” section to the blog.
Bill
October 30th, 2008 at 8:20 am
P.S. Judging by the fact that several thousand people have downloaded SB in its months of existence (at least 50 people visit this blog per day), I’m betting that it is probably online at many Rails sites that use forums.
November 5th, 2008 at 12:09 pm
Hi all. No update for Rails 2.1 ? I’ve a lot of difficulties with routes
undefined local variable or method `users_path’
or
undefined local variable or method `new_session_path’
even my restful seems kaput:
No route matches “/login” with {:method=>:get}
:((((
if someone has an idea…
I’m running Rails 2.1.2 & engines 2.1.2
November 5th, 2008 at 12:20 pm
mode autoresponse: It seems that ‘map.from_plugin :savage_beast’ is not working in my route.rb…
If I take all routes defined in ‘vendor/plugins/savage_beast/routes.rb’ and put it directly in route.rb of my app, it’s working. cool.
November 5th, 2008 at 5:25 pm
We use it on our site. http://www.rubysoccer.com