Minggu, 08 April 2012

cucumber-rails-1.0.2/lib/cucumber/rails.rb:4:in `dirname': can't convert nil into String (TypeError)

cucumber-rails-1.0.2/lib/cucumber/rails.rb:4:in `dirname': can't convert nil into String (TypeError)

gem update cucumber-rails

should solve the problems ;)

Sabtu, 07 April 2012

protocol.rb:135 - Resource temporarily unavailable - read would block

if youre having that error.

reinstalling rvm may resolve your problem.

here is the link

Click here

Rabu, 04 April 2012

bundle install not install the gems

i was having a problem when im running bundle install, and the process are not fecth completely

to fix that i just have one source on my .gemrc file

:update_sources: true
- http://gems.github.com
:benchmark: false
:bulk_threshold: 1000
:backtrace: false
:verbose: true
gem: --no-ri --no-rdoc

Senin, 02 April 2012

open xls files in rails 3

when i m stuck working on my projects to open xlsx files into my ruby on rails app,
i found this gems, and its easy to use :

  [sudo] gem install roo

For further information you could refer to this :

Click here...

Rabu, 14 Maret 2012

Count a spesific character in mysql

if you want to count a spesific character on a string you could use:

select *, LENGTH(REPLACE(email, '@', '')) AS occurrences from tables

Kamis, 16 Februari 2012

How to change string in multiple files in UNIX

sed -i 's/named_scope/scope/g' *.rb

where is
"named_scope" the string that you want to replace
"scope" the new string.

Jumat, 16 Desember 2011

Parsing XML with Nokogiri

There are so many related articles about this things.

But i want to write down the spesific about how to parsing xml on nokogiri,

   require 'open-uri'
   doc = Nokogiri::HTML(open("http://www.w3schools.com/xml/note.xml"))   

This is the result example:

Click it. This is the sample xml:

         The Xml File

and you want to get the "Jani" from the xml.

here what we do

because Jani is children from note node.
so we have to call the note first.

we will get the note's children.:

      result = doc.xpath('//note')            
and last, after we get the children. we parse with :

      result = result.xpath('//from').text           

Or, we could make it simplifier by:

     doc = Nokogiri::HTML(open("http://www.w3schools.com/xml/note.xml")) 
     result = doc.xpath('//note/from').text      
# in this case, we are find for the root of "note", and then search the children node, named "from". and this will be "JANI"

Hope it will helps
Copyright 2009 ruby on rails. Powered by Blogger
Blogger Templates created by Deluxe Templates
Wordpress by Wpthemescreator