Saturday, June 30, 2012

Nokogiri installation error in Rails

Building native extensions.  This could take a while...
ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

        /Users/user/.rvm/rubies/ruby-1.8.7-p352/bin/ruby extconf.rb
checking for libxml/parser.h... yes
checking for libxslt/xslt.h... yes
checking for libexslt/exslt.h... yes
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... yes
checking for xmlParseDoc() in -lxml2... yes
checking for xsltParseStylesheetDoc() in -lxslt... yes
checking for exsltFuncRegister() in -lexslt... yes
checking for xmlHasFeature()... no-----
The function 'xmlHasFeature' is missing from your installation of libxml2.  Likely this means that your installed version of libxml2 is old enough that nokogiri will not work well.  To get around this problem, please upgrade your installation of libxml2.
This is fixed with the following:

brew install libxml2 libxslt
brew link libxml2 libxslt
gem install nokogiri

Tuesday, June 26, 2012

Dispatcher and SynchronizationContext classes in WPF

  1. Use the Dispatcher when your code is tightly coupled to WPF. 
  2. Use the AsyncOperationManager when you need to queue something on the 'Context' thread. This works with Windows Forms, ASP .NET and WCF applications as well. 
  3. Avoid using the SynchronizationContext yourself. The AsyncOperationManager uses this mechanism internally. 

SynchronizationContext.Current object is of type DispatcherSynchronizationContext which is actually just a wrapper around the Dispatcher object and the Post and Send methods just delegate to Dispatcher.BeginInvoke and Dispatcher.Invoke.

So even if you decide to use SynchronizationContext I think you end up calling dispatcher behind the scenes.
Besides, supposedly, it is a bit cumbersome to use SynchronizationContext as you have to pass a reference to the current context to all threads that need to call into your UI.

Monday, June 11, 2012

Using form_tag in Ruby on Rails

In controller a "new" action creates a sample object that is just a simple object, not ActiveRecord :

  def new
    @item =

"Create" action is a post action

  def create

And in the view the following code just displays Item object fields and posts back a hash with fields filled in on the client side:

This will create the following markup:

Relevant references:

Powered by Blogger.