Ruby 1.8 (supplied by Rails' ActiveSupport) >> BigDecimal.new("0.1").floor.class => BigDecimal Ruby 1.9 (supplied by Ruby 1.9 itself) >> BigDecimal.new("0.1").floor.class => Fixnum In fact, Float#floor has changed from Ruby1.8 to...
...or by setting self.primary_key = "id" in your class definition. Related, but different issue: Rails 2 does not find an association when it is named with a string instead of...
...let pages pop up as errors occur), the capybara-20120326132013.html files will clutter up your Rails root directory. To tell Capybara where it should save those files instead, put this into...
Then I should see "Welcome!" What happens here is that the Rails application serving pages runs in 2017, but the process running your browser still lives today...
When a Rails controller action should handle both HTML and JSON responses, do not use request.xhr? to decide that. Use respond_to. I've too often seen code like this...
...of Carrierwave and Capybara, has released Refile, a gem for handling file uploads in Rails. It handles direct uploads (also direct uploads to Amazon S3) better than Carrierwave.
...for a gem, e.g. when you want to see if there is a newer Rails 2 version of your currently used gem. At first you should search your gem at...
...might get the above error message when cloning certain git repositories (for example the rails repository). It indicates that there is a malformed timestamp in some commit, and your git...
In a Rails application, *_spec.rb files get special treatment depending on the file's directory. E.g. when you put a spec in spec/controllers your examples will have some magic context...
RubyGems 1.6.0 has undergone some changes which may cause Rails 2.x applications to break with an error like this one (e.g. when running script/server): /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:55: uninitialized constant ActiveSupport...
...the error above you can also add require 'thread' in your boot.rb after the RAILS_ROOT constant was defined. RAILS_ROOT = "#{File.dirname(FILE)}/.." unless defined?(RAILS_ROOT) require 'thread...
...saving etc), do this: Model._save_callbacks.select {|cb| cb.kind == :before}.map{ |c| c.instance_variable_get :@filter } Rails 2 User.after_save_callback_chain To look at the method names only, you could do...
...the poor decisions made at every turn. “Why, oh why, is this built with Rails when Node.js would be so much better?” or “how could the previous developer not have...
...Windows VM copies them over a Samba share onto your machine. From inside your Rails project directory call regularly: geordi remove-executable-flags Runs chmod -x on Ruby, HTML, CSS...
...joins, ActiveRecord will make that record read-only. This is a protective measure by Rails because such a record might have some additional attributes that don't correspond to actual...
...to deliver a real Unit object, whereas form.select :unit_id, Unit.for_select will make Rails typecast the String value from the select field to the unit's ID...
Ancestry is a gem/plugin that allows the records of a Ruby on Rails ActiveRecord model to be organised as a tree structure (or hierarchy). It uses a single, intuitively formatted...
In Rails, you can very easily send emails with HTML and plaintext bodies. However, if you're trying to debug those using your normal email account, you might be out...
...to whatever you like (by returning old_value you'd get the behavior of Rails' reverse_merge!, by returning new_value you'd get the behavior of standard merge!).
In the ruby shell (IRB) and rails console the return value of the previous command is saved in _ (underscore). This might come in handy if you forgot to save the...
...Ruby couterpart. Thus, it does a great job as YAML-doc, e.g. when writing Rails locale files. Did you know that ... << is a merge key (similar to & in SASS)
...to remember the password, give a form an autocomplete attribute with the value off: ... Rails example form_for @model, :html => { :autocomplete => "off" } do |form...
Under certain circumstances gettext_i18n_rails will hit a near-infinite loop. This occured in Rails 2.3.5 with Haml 3.0.18 and fast_gettext 0.5.10. gettext_i18n_rails's Haml-Parser...
...on our radar for a while. They seem to have made significant progress running Rails, reducing start-up time and becoming runtime-independent of the JVM. Also see Running Optcarrot...
If you have a file that looks like a precompilation fingerprint, the Rails asset pipeline will not see it. So don't have filenames like this: 8e21264d-f678-4005-b90c-8d8288a0d179.ttf