To simulate Rails' to_sentence in your JavaScript application, you can use these few lines of CoffeeScript code: joinSentence = (array) -> if array.length > 1 array[0..-2].join(', ') + ', and ' + array...
...you don't have a route that responds to /__identify, Capybara will wrap your Rails app in a middleware that responds to that path...
...staging or production environments, chances are that JavaScript compression is the culprit. By default, Rails 3.2 compresses JavaScript with UglifyJS. I have seen a few cases where this actually breaks...
...to check all traits for mistakes. This behavior is likely to be caused by Rails' autoloading...
Also compare our card Test if two date ranges overlap in Ruby or Rails...
...the gem. The gem is there for you should you one day upgrade to Rails 3.2+. Please don't use the defaults gem which we original forked away from in...
...once again and check for such things thoroughly before heading into the depths of Rails or your application's logic...
...disabled, that all classes are already loaded when browser interaction takes place what makes rails able to find the class even without the namespace...
...for features. If you don't have separate environments, you can't check your Rails.env. I managed to distinguish between specs and features by asking Capybara. Note that this only...
Sometimes the Rails helper #distance_of_time_in_words is using too much magic. When you need a time difference in a specific unit, use this method: ^ def distance_of...
...to iterate over every Monday in a range of Dates. If you are using Rails or ActiveSupport, calling step without a block will return an array of matching elements...
...but completely different card: Detect if a Javascript is running under Selenium WebDriver (with Rails...
Rails doesn't know which host it is running on. For generating links, it strips the hostname off the request URL, which can lead to errors when you have absolute...
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...
The bin/webpack-dev-server command is not as smart as e.g. rails server, where it shows the proper fix within the error message. $ bin/webpack-dev-server yarn run v1.19.1 error Command "webpack-dev-server...
...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...