Posts for: #Plugins

Click To Globalize: Rails 2.0 Ready

I have finished to work on Click To Globalize, to made it Rails 2.0 compatible.

What’s Changed?

All and nothing: from the user point of view, the plugin has the same behaviors of the previous version. My recent activity was a refactoring, now it:

  • Works with CSRF Killer
  • Works with Prototype 1.6.0.1 and Scriptaculous 1.8.0.1
  • Works with rewritten version of Scriptaculous Ajax.InPlaceEditor
  • Works with new Prototype events handling
  • Uses new Prototype’s Element#addMethods and Function#wrap to add methods and AOP
  • Uses Protoype Hash#get, instead of square brackets
  • Uses .html.erb as helper, instead of .rhtml
  • Has a more clean installation/disinstallation process
  • Has DRYed up tests
  • Hasn’t prototype.js into the packaging

How To Use It?

Rails 2.0
$ ./script/plugin install http://dev.23labs.net/svn/rails/plugins/click_to_globalize/trunk
Rails 1.2.x
$ ./script/plugin install http://dev.23labs.net/svn/rails/plugins/click_to_globalize/branches/for-1.2.x

For a detailed guide, howtos, snippets, video-tutorials and other infos, please visit the Click To Globalize page.

[]

Acts As Resource: Rails 2.0 Ready

Acts As Resource is ready for Rails 2.0!!

This plugin combines both ActiveRecord and ActiveResource features in one class. It easily allows to deal with a remote REST service or with a local database.

If you want read more visit the plugin page or install with:
$ ./script/plugin install http://dev.23labs.net/svn/rails/plugins/acts_as_resource

[]

Click To Globalize: Working On Rails 2.0 Compatibility

As you already know, Rails 2.0 it’s shipped with updated version of Prototype and Scriptaculous.

Prototype team has committed some breaking changes (e.g. Hash class), and Scriptaculous now has a brand new, rewritten InPlaceEditon.

Those elements are fundamental for Click To Globalize and I’m working on new version for Rails 2.0.

Be patient, I’ll soon release it.

[]

Acts As Resource: Combining ActiveRecord and ActiveResource

Would you use both ActiveRecord and ActiveResource in one class? Now with Acts As Resource you can!!

Example

class Carrot acts_as_resource self.site = 'http://localhost:3000'
belongs_to :bunny

validates_presence_of :color
validates_uniqueness_of :color
validates_length_of :color, :within => 2..23,
                    :if => lambda { |c| c.color && !c.color.empty? }
validates_format_of :color,
                    :with => /[\w\s]+$/,
                    :if => lambda { |c| c.color && !c.color.empty? }

before_create :please_call_me_before_create
def self.validate
  logger.debug("VALIDATE #{color}")
end

def please_call_me_before_create
  logger.debug("Ohhh, so you called me..")
end

end

[]

Rails: How to force plugins loading in 2.0

Sometimes a Rails plugin can be dependant from another one. Since plugins are loaded in alphabetic order, probably you need to load the third part plugin first.

The release 1.2.4 2.0PR introduces breaking changes for this mechanism.

I’m developing a plugin called ClickToGlobalize, that’s dependant on Globalize, here the code for plugin initialization:

# Force Globalize loading. if Rails::VERSION::STRING.match /^1\.2+/ load_plugin(File.join(RAILS_ROOT, 'vendor', 'plugins', 'globalize')) else Rails::Initializer.run { |config| config.plugins = [ :globalize ] } end
require 'click_to_globalize'

Explanation

Use the old mechanism if the current release is minor than the last release with it (1.2.3 1.2.4), else use the Rails::Initializer class.

[]