Nov 19, 2008
The first ruby full day event of its kind is to be held on 22nd November, 2008 at Impetus, Noida.
Here are the highlights of the day…
- Flex on Rails
- Internationalization Rails
- FxRuby & ActiveRecord
- Facebook App on Rails
- Integrating Voice gateways in Rails
- Soft Rock
More details on event and venue can be found at rubyonrails.in
See you there.
Nov 19, 2008
TinyMCE is an excellent WYSIWYG editor. The same can be used in rails with this plugin. In many cases, we need to toggle tinymce editor on/off. For this add the following lines to tiny_mce_helper.rb file of your plugin just before javascript_tag tinymce_js line in tiny_mce_init method.
tinymce_js += %Q! function toggleEditor(id) {
if (\!tinyMCE.getInstanceById(id))
tinyMCE.execCommand('mceAddControl', false, id);
else
tinyMCE.execCommand('mceRemoveControl', false, id);
}
!
And you can easily place a link beside your editor to toggle something similar to:
<%= link_to_function "Add/Remove Editor", "toggleEditor('name')" %>
Here name is the name of the textarea/textbox to which you are applying tinymce editor.
Recent releases of tinymce would require to use tinyMCE.get(id) instead of getInstanceById(id) in code above.
May 29, 2008
One of the available plugins for time based fragment caching is timed_fragment_cache by Richard Livsey. A mirror for the plugin is available here at GitHub.
One of the limitation of the plugin is the inability to explicitly expire fragment cache, specifically in our sweeper. The method expire_fragment just clears the cache file but corresponding meta file which stores the time of expiration remains. You can add the following to your environment.rb to clear the meta file and explicitly expire cache in addition to automatic timed expiration feature offered by plugin.
module ActionController
module Caching
module TimedFragment
def expire_meta_fragment(name)
expire_fragment(meta_fragment_key(name))
end
end
end
end
Now, in sweepers just call this new method along with expire_fragment method.
class ArticleSweeper < ActionController::Caching::Sweeper
observe Article # This sweeper is going to keep an eye on the Article model
# If our sweeper detects that an article was created call this
def after_save(article)
expire_cache_for(article)
end
# If our sweeper detects that an article was deleted call this
def after_destroy(article)
expire_cache_for(article)
end
private
def expire_cache_for(record)
# Expire the fragments now that we posted a new article entry
expire_fragment({:controller => 'articles', :action => 'index'})
expire_meta_fragment({:controller => 'articles', :action => 'index'})
end
end