Ruby is just so simple:
ruby-1.8.7-p302 > 'ff'.to_i 16 => 255 ruby-1.8.7-p302 > 255.to_s 16 => "ff"
Building native Ruby extensions on Windows requires a little bit of extra work. Here’s how it goes:
C:\Documents and Settings\Stefan>gem install ruby-debug Building native extensions. This could take a while... ERROR: Error installing ruby-debug: ERROR: Failed to build gem native extension. C:/Ruby187/bin/ruby.exe extconf.rb creating Makefile make 'make' is not recognized as an internal or external command, operable program or batch file. Gem files will remain installed in C:/Ruby187/lib/ruby /gems/1.8/gems/linecache-0.43 for inspection. Results logged to C:/Ruby187/lib/ruby/gems/1.8 /gems/linecache-0.43/ext/gem_make.out
That’s it, building and installing native extensions works now like a charm
C:\Documents and Settings\Stefan>gem install ruby-debug Building native extensions. This could take a while... Building native extensions. This could take a while... Successfully installed linecache-0.43 Successfully installed ruby-debug-base-0.10.4 Successfully installed ruby-debug-0.10.4 3 gems installed Installing ri documentation for linecache-0.43... Installing ri documentation for ruby-debug-base-0.10.4... Installing ri documentation for ruby-debug-0.10.4... Installing RDoc documentation for linecache-0.43... Installing RDoc documentation for ruby-debug-base-0.10.4... Installing RDoc documentation for ruby-debug-0.10.4...
Update:
For detailed documentation please check out these links (thanks to Luis Lavena):
https://github.com/oneclick/rubyinstaller/wiki/Development-Kit
https://github.com/oneclick/rubyinstaller/wiki/Tutorials
Using ActiveRecord’s serialize method you can save Ruby objects in a single field of your model. The serialization is done through YAML.
Today I tried to save a nested object structure with this method. These are the classes:
class PhotoStyle attr_accessor :image def initialize @image = StyleElement.new end end class StyleElement attr_accessor :selector, :style def initialize @selector = '*' @style = {} end end
The model which saves a PhotoStyle object:
class Photo < ActiveRecord::Base serialize :style, PhotoStyle end
This first approach didn’t quite work out. Saving the model worked fine, but when I loaded it only PhotoStyle got deserialized to the original type. The nested StyleElement didn’t:
p = Photo.last p.style => #<photostyle:0xb70a906c @image=#<YAML::Object:0xb72079a4 @ivars={"selector"=>"#theimage", "style"=>{"border"=>"0", "box-shadow"=>"1px 3px 15px #555"}}, @class="StyleElement">}, @class="PhotoStyle">> </photostyle:0xb70a906c>
Note the YAML object assigned to the @image instance variable.
I'm not sure if that's a bug in Rails3 or if that is by design. You can however "fix" it by running this code snippet when your application starts up:
YAML::Syck::Resolver.class_eval do def transfer_with_autoload(type, val) match = type.match(/object:(\w+(?:::\w+)*)/) match && match[1].constantize transfer_without_autoload(type, val) end alias_method_chain :transfer, :autoload end
Save it e.g. in yaml_autoloader.rb in the config/initializers folder of your app.
Now all types will autoload:
#<photostyle:0xb73dcb08 @image=#<StyleElement:0xb73dd058 @selector="#theimage", @style={"border"=>"0", "box-shadow"=>"1px 3px 15px #555"}>> </photostyle:0xb73dcb08>
I found above code snippet here. Thanks!
Read more about ActiveRecord's serialize method here: Simple user preferences for your Rails app.
Update:
Still not sure if that's a bug, but I submitted a lighthouse ticket.
Update 2:
Apparently this is not a bug in Rails, but a problem in my code :-) Please see Aaron's comment in above ticket.
JRuby and Ioke on Google App Engine for Java
key topics:
All in all I got the feeling that you shouldn’t run your production Rails application on AppEngine yet. There are to many caveats currently. It might be worth considering to move specific services of your application to AppEngine though. Especially those which could benefit most from the scaling advantages in the cloud.
The main points for getting your Rails app running on AppEngine you can read here and here.