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.

The plugin is currently in an alpha stage, so I figure I’ll start versioning it and use this post as a spot to document the installation instructions as they evolve.

Installation

Currently, the following is necessary to use the Savage Beast plugin:

  1. The Savage Beast 2.0 plugin. Go to your application root directory and:
    svn export http://savage-beast-2.googlecode.com/svn/trunk/ vendor/plugins/savage_beast

  2. 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‘)
  3. Copy the migration in /vendor/plugins/savage_beast/db/migrate into your own migration directory (and run it)
  4. 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
  5. Add the line “map.from_plugin :savage_beast” to your routes.rb.  Location shouldn’t matter unless you intend to override it.
  6. Add the line “include SavageBeast::UserInit” to your User model.  Location shouldn’t matter unless you intend to override it.
  7. 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.

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. I haven’t made a pass for security yet — looks like by default forums could be edited or deleted by pretty much any old user. And of course, there’s sure to be bugs, which you can report via the comments below, or the Google Code project. 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.

65 Responses to “Savage Beast 2.0 - A Rails 2.0 Message Forum Plugin”

  1. Eric Anderson Says:

    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.

  2. Ben Says:

    Very cool! Thanks SO much for doing this.

  3. Andrew Says:

    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

  4. Rasmus Says:

    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

  5. Bill Says:

    @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)

  6. Bill Says:

    @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?

  7. Galdrian Says:

    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.

  8. Bill Says:

    @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…

  9. Rasmus Says:

    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).

  10. Justin Says:

    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?

  11. Bill Says:

    @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)

  12. Justin Says:

    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?

  13. Justin Says:

    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.

  14. Justin Says:

    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

  15. Justin Says:

    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’

  16. Justin Says:

    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.

  17. Bill Says:

    @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.

  18. Jim Says:

    @Justin: If you don’t mind my asking what was the issue with the uninitialized constant ForumController error? I’m getting the same error.

  19. Jim Says:

    Nevermind, I figured out what was going on with the uninitialized constant ForumsController error.

  20. Kamaitati Says:

    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’)

  21. Kamaitati Says:

    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?

  22. Kamaitati Says:

    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…

  23. Kamaitati Says:

    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

  24. Justin Says:

    @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.

  25. Bill Says:

    @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.

  26. Bill Says:

    @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.

  27. Justin Says:

    @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 :)

  28. James Says:

    Just for reference you may need the will_paginate plugin installed too. I did at least. (http://rock.errtheblog.com/will_paginate).

  29. Bill Says:

    @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.

  30. Piotr Says:

    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

  31. Bill Says:

    @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.

  32. Adam Says:

    @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.

  33. Adam Says:

    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!

  34. Bill Says:

    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.

  35. Peter Says:

    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!

  36. Bill Says:

    @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.

  37. Bill Says:

    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.

  38. Chuck Says:

    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.

  39. Foo Bar Says:

    Hey, where’s the default title variable located?

  40. Bill Says:

    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)

  41. Foo Bar Says:

    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.

  42. Foo Bar Says:

    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.

  43. Foo Bar Says:

    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.

  44. RORnoob Says:

    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?

  45. JohnathanWinters Says:

    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

  46. ryan Says:

    how do you force application.rb and user.rb to load in env.rb??

  47. ryan Says:

    savage beast 2 somehow make my rails messages dutch!!!
    how do i fix that?

  48. Bill Says:

    See the docs for the gibberish plugin, which is what SB2 uses for localization.

  49. ryan Says:

    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!

  50. Sonia Says:

    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

  51. ryan Says:

    nevermind…i screwed up something…
    great plugin btw..

  52. Bill Says:

    @Sonia@: The original Savage Beast is the answer for Rails 1.x’ers: http://nnovation.ca/blog/

  53. ryan Says:

    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’

  54. Ram Says:

    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

  55. Ram Says:

    “undefined method fond_ordered for …”
    should read
    “undefined method find_ordered for …”

    I see that this method is defined in the SB plugin.

  56. Jim Says:

    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.

  57. Krzysztof Says:

    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

  58. Bill Says:

    @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… :)

  59. ryan Says:

    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

  60. Bill Says:

    @ryan@: Thanks buddy! I’ve updated the source with your change.

  61. Ron Evans Says:

    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!

  62. Krzysztof Says:

    Hi,
    where should i set value of variables users_path and forums_paht, any maybe other?
    thank you in advance
    Krzysiek

  63. Zac Says:

    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.

  64. Bill Says:

    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.

  65. tito Says:

    Hi do you have a solution to prevent simple users from creating forums or editing/deleting other user’s posts?
    Thanks.

Leave a Reply