# migration to Rails3.

6 posts, 2 voices

Hi,

I am using Instiki, as a sort of content backend for my website. It’s a base for the website application, which needs additional functionality, which I would like to build on the latest rails 3.x. So I rolled up my sleeves and started to migrate Instiki to Rails 3, which is now almost complete. The approach is pragmatic, fixing things when they break in Rails3. I have recorded all the adaptation, and this could be a check list to ‘replay’.

So here is the thought. I would like to share this experience and help out if there is a interrest to push the original instiki to Rails3. I would however need some help from the original developers.

I can clone the original, but then would like to push it back to the original git, of course in another branch, and when all ok, that could become the new official version… what do you say?

Cheers Christophe

Hi, (Jacques, I hope you are reading this!)

I am running into a tricky problem in the Rails3 migration. As you likely know, Rails 3 doesn’t load the /lib directory when starting. There are 2 options to auto-load. 1) In application.rb (which is required by Rails 3) put in a config parameter to load. There are some caveats as the names of the files versus the names of the class. 2) there is now a /config/initializers directory, and .rb is executed here.

What I have done now is:

1) config/application.rb

This will load most files, except InstikiErrors and WikiContent as the naming of the files doesn’t fit the rails loading algorithm. To load these I use:

2) config/instiki_init.rb

require ‘instiki_errors’ require ‘wiki_content’

(I also had to rename the wiki.rb class in /chunks/wiki as rails would complain, the file should declare the Wiki class ) “Expected /Users/Christophe/Documents/Spaces/netxforge_aptana/com.netxforge.store/lib/chunks/wiki.rb to define Wiki

This /lib classes are loaded, however I run into a problem when saving a page. What happens is that somehow the methods in WikiChunck Module are not available .. so it seems the mixin of this module into the WikiContent class is not working well… I know it’s a fuzzy description but I get for example the following error. You see this occurs in the PageRenderer, when calling ‘update_references’ while prior to that the method ‘render(…)’ is called which creates the variable ‘rendering_result’ correctly created. (Also some of the mixin methods should have been called by then). I am really puzzled about this. I even consider rewritting it, so that mixin is not used. (I actually wonder why a mixin solution was chosen here, it’s not code re-use is it?).

Can you help me fix this?

Here is the error:

NoMethodError in WikiController#save

undefined method find_chunks’ for #<ActiveSupport::SafeBuffer:0x007ff4863dc368>

Rails.root: /Users/Christophe/Documents/Spaces/netxforge_aptana/com.netxforge.store Application Trace | Framework Trace | Full Trace

lib/page_renderer.rb:122:in wiki_links' lib/page_renderer.rb:102:in find_wiki_words’ lib/page_renderer.rb:150:in update_references' lib/page_renderer.rb:141:in render’ lib/page_renderer.rb:29:in display_content' app/models/page.rb:30:in revise’ app/models/wiki.rb:79:in revise_page' app/controllers/wiki_controller.rb:325:in `save’

Teaser below :-), Instiki on rails3.

Ah, found the problem for the issue, I reported earlier. … (took me the better part of the morning grrrr…). Ok, so WikiContent extends ActiveSupport::SafeBuffer. Now this class changed in Rails 3, overriding (Or opening up in Ruby Parlence) with the following code:

def html_safe ActiveSupport::SafeBuffer.new(self) end

So, this produces a different Class type, hence the mixed-in methods get lost! and causes a problem in PageRenderer trying to call this method. Wow, I am happy I found this one.

the file holding this method is called: output_safety.rb in lib/activesupport/kernel. I couldn’t find the alternative for Rails 2.3, to prove my point. but regardless it now works, by commenting out this line in WikiContenr.render!

# self.html_safe

BTW: The teaser screenshot is now shown, in my previous post.

This is extremely interesting.

Porting Instiki to Rails3 has long been on my TODO list. But (as you’ve seen), it’s not a small job. So it keeps getting pushed back in favour of other things. So I’m really happy you’re working on this!

Hi,

I have it working (mostly), today spend some time fixing

• asset pipeline for rails3
• further clean-up
• big issue running with passenger, rvm etc…

so, the test site is running here:

http://test.netxforge.com => This is the front site, which “presents” the wiki pages. http://test.netxforge.com/netxforge/list => The actual wiki

There are a some pending issues, with URL generator, making some links not working.. etc.. so still a bit of work….

Cheers Christophe

Here are the steps to follow: