ruby

When using Sequel ORM; when to use Core or Model?

I'm looking to expand my ruby knowledge beyond scripting, test code and file parsers by writing some web services. I'm thinking of using sequel as an ORM. What advantages are there to using Sequel Core or Sequel Model? What should I be looking out for? What rules of thumb are there for picking one or the other? ...

Can you do an :order in ruby after a find?

Is it possible in ruby/rails to order a result set after doing a find? For example, is it possible to do something like this Warning: Does not work if type == 1 @items = mycompany.items else @items = myhome.items end @items = @items :order => "created_at" I would assume something like this should be possible, but I'm still very...

Converting a UCS2 string into UTF8 in Ruby

How to convert a string that is in UCS2 (2 bytes per character) into a UTF8 string in ruby? ...

Does using JRuby mean a duplicate of Ruby on all applications?

For example, if I install Rails for regular Ruby, am I required to have a special install of Rails for JRuby? So that I have duplicates for everything? ...

Search in Ruby On Rails

I have a small site with about 500 photos and 150 visitors per day which is hosted on Dreamhost. I would like to add a simple search engine that does not need to run long time processes which are not allowed on shared host. The search engine should process different fields belonging to various models: Photo, Photo.author.name, Photo.com...

Extending a rails plugin

Hello, I need to extend a plugin by overwriting a method and adding one of my own. So far I have followed Strictly Untyped's guide for this but I haven't had much success. Basically there is a file in the initializer folder that loads the extension from the lib directory. In my initializers folder I have a file with this: require 'amaz...

Is it feasible to use Ruby 1.9 for Rails yet?

I've read that Ruby 1.9 is a lot faster than 1.8, however it seems like it hasn't become the standard in the Rails community yet. What are the pros and cons of using Ruby 1.9 for new apps? Edit to say: What I found confusing was that while its not officially recommended, it seems like 2.3 brought compatibility. Just wondering if people ...

Testing the Ruby on Rails weblog(netbeans edition)

I recently started learning ruby on rails. I completed the weblog walkthru(links below) and want to make tests for it. I took this functional testing from the video version of the weblog demo. Now i want to make this testing work for the netbeans edition, which actually is structured differently in terms of how the comments relates to th...

Ruby email encoding and quoted-printable content

Is there a straightforward way to coach TMail to make the body encoded with "quoted-printable"? I only see methods in there for decoding content like that, not creating it. ...

Authlogic and Namespace in Rails

Does anyone have an example of setting up Authlogic with a namespace in Rails? I have an "admin" namespace, which contains many "admin" related controllers (products, categories, etc.). map.namespace :admin do |admin| admin.resources :products, :active_scaffold => true admin.resources :specials, :active_scaffold => true admi...

Determine if a string is a valid float value

Is there a way to simply check if a string value is a valid float value. Calling to_f on a string will convert it to 0.0 if it is not a numeric value. And using Float() raises an exception when it is passed an invalid float string which is closer to what I want, but I don't want to handle catching exceptions. What I really want is a meth...

Is alias_method_chain synonymous with alias_method?

If these two methods are simply synonyms, why do people go to the trouble of writing the additional characters "_chain"? ...

Best way to learn how to combine Blueprintcss and Compass/Sass?

I would like to apply Blueprintcss and Compass/Sass to a Rails project. Should I learn Blueprint first or Compass/Sass first or are there any guides on how to use the two of these together? Also, does it make any difference that it's a Rails project? Could this combination of technologies be just as easily applied to, say, a Java proje...

Common usage of Rails applications ?

What are the most common tasks for Rails applications? I mean, for example, for small and simple sites people usually choose PHP, because it's really easy to maintain and to deploy, most hosting platforms support all your needs. But I'm interested what people usually produce with Rails. What kind of applications? ...

Best way to combine fragment and object caching for memcached and Rails

Lets say you have a fragment of the page which displays the most recent posts, and you expire it in 30 minutes. I'm using Rails here. <% cache("recent_posts", :expires_in => 30.minutes) do %> ... <% end %> Obviously you don't need to do the database lookup to get the most recent posts if the fragment exists, so you should be able to...

does Rails 2.3 support a file-based session store?

Does Rails 2.3 support a file-based session store out of the box any more? It looks as though it supports only use of active_record_store and mem_cache_store, in addition to the default cookie-based. If it does support a file-based session store, how is that configured? It seems as if it should be easy to find a definitive yes or no ans...

Flatten an array of hashes in ruby

I have some simple code that looks like this: fruit.each do |c| c.each do |key, value| puts value end end This works fine, but it feels un-ruby like. My goal is to take this array: [{"fruit_id"=>"1"}, {"fruit_id"=>"2"}, {"fruit_id"=>"3"}] And convert it to this: [ "1", "2", "3" ] Thoughts? ...

Dynamic languages - which one should I choose?

Dynamic languages are on the rise and there are plenty of them: e.g. Ruby, Groovy, Jython, Scala (static, but has the look and feel of a dynamic language) etc etc. My background is in Java SE and EE programming and I want to extend my knowledge into one of these dynamic languages to be better prepared for the future. But which dynamic l...

LocalJumpError (Ruby on Rails)

Hi I have searched/Googled around but I'm struggling with the following problem. I am building a Rails 2.3.2 application and one of the requirements is to calculate the median of an array of results. I am using code for calculating the median from the Ruby Cookbook but keep running in to a problem with receiving an error 'LocalJumpErr...

APIs that allow status updates to be posted to several sites?

Does anyone know of an API that will allow for posting status updates to Twitter, LinkedIn and Facebook? ...