How do I get RForum running from a sub-directory (/forum)? I thought I could just change the Rewritebase to /forum but that doesn't work. Thanks in advance.
on 2006-06-19 03:53
on 2006-07-07 11:53
Benjamin Arai wrote: > How do I get RForum running from a sub-directory (/forum)? I thought I > could just change the Rewritebase to /forum but that doesn't work. > Thanks in advance. The changes you need to make are extensive, because RForum has a number of places where it hard-codes URLs thereby igoring any sub-directory that you specify. The basics for any Rails application are onerous enough: (1) Edit config/routes.rb and add the subdirectory to the paths in the various map.connect lines - e.g.: map.connect '', :controller => 'forum', :action => 'list' ...becomes: map.connect '/forum', :controller => 'forum', :action => 'list' You might want to do it using a variable instead (e.g. PATH_PREFIX) set up in one of the environment files, in case you ever want to move the forum or make a copy of your installation on a different server under a different subdirectory. map.connect PATH_PREFIX + '', :controller => 'forum', :action => 'list' (2) Tell the Helper URLs that you're not running from root. You do this by hijacking the "asset host" stuff, so that images, scripts, CSS etc. are fetched from a different location. This only works for places where a helper method has been called to generate a URL, so all Rails apps should do this for all URLs, but many don't and RForum is a good (bad?) example. Somewhere within the "Rails::initializer.run do |config|" block of config/environment.rb, add: config.action_controller.asset_host = "/forum" Now whether or not "/forum" works will depend on whether a path such as "/forum/images/something.png" would work OK on your host. That will in turn depend on where the Rails application's "public" folder lives. So modify the line above in order to generate correct links for wherever your Web server will go for items in the RForum "public" folder. (3) If you run RForum out of a subdirectory the implication is that you may want to run multiple Rails applications on one host. If you do this, the name of the session cookies used by each will clash. To avoid this, give the cookie a unique name. In config/environment.rb or in one of the files in config/environments, add the following line *outside* the "Rails::initializer.run do |config|" block: ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS[:session_key] = 'rforumapp_session_id' You can use whatever name you want, it doesn't have to be "rforumapp_session_id". For many Rails applications, that's enough. There may be the odd rogue hard-coded URL to sort out. For RForum, there are loads of them. Check the skin CSS files - CSS is a weakness for Rails, because you can't use ERB in CSS files so URLs to images and so-on *must* be hard-coded. If you're using a skin that references images you may, depending on where you've put "public", need to change the URLs in the CSS files. You're going to have to do some work with things making calls to any method in the Mailer class (app/controllers/mailer.rb) because most methods take a URL to include in a notification e-mail message. For some reason in several places RForum callers construct URLs "by hand" using @request.host and so-on. You need to change those into equivalent "url_for" calls, e.g. in places like app/controllers/user_controller.rb where it's calling deliver_registration_mail. You will similarly need to look in the various app/views fragments to check for hard-coded URLs there; it's been a while since I looked at those since they were the first things I changed but ISTR similar issues with URLs written into the RHTML where helper method calls should have been. There were a couple of more tricky cases that I may have temporarily just hard-coded to my own subdirectory in lieu of a proper fix at a later time. Incidentally, if you're using PostgreSQL not MySQL you'll find searches don't work because RForum uses a "LIMIT x,y" query form which PostgreSQL doesn't understand. In app/models/search_like.rb, change "LIMIT ?,?" to "OFFSET ? LIMIT ?" to get what ought to be identical functionality that'll work in either database. Doing all of this is a pain, which is why I'm offering to put these fixes into the tree. For free, out of the goodness of my heart :-) - except the authors haven't responded to e-mail and nobody on this forum, yet, has suggested where I should be going to submit such patches, and all my IRC pleas to date have fallen on deaf ears. So I've a (almost completely) relocatable version of RForum but nobody else can use it right now. Doh. Can anyone help?
on 2006-07-07 11:54
I wrote: > (1) Edit [...] Grrr. Sorry about the formatting. It seems the text area width is not accurately representative of the hard-wrap width set within RForum.
on 2007-01-26 04:04
on 2007-01-26 16:40
> Since this is an inclusive solution that doesn't break one side or the > other, I suggest it gets submitted to the darcs RForum codebase - any > ideas how I should go about doing this? To respond to myself, since I wasn't sure about the protocol on this, I sent the darcs patch over to Andreas via email (using darcs and surprised how nice darcs is to use) and hoped this was the right (and not too rude) way of doing this. Apologies if this is not the right way. I would be happy to submit it another way. Thanks, SP
on 2007-01-26 21:21
Hi, I didn't receive your patch. What address did you send it to? Andreas
on 2007-02-06 21:37
Andreas Schwarz wrote: > I didn't receive your patch. What address did you send it to? For others following this thread, Andreas and I email each other off the forum and about 10 days ago Andreas committing my patch to fix this issue.