View
External content

ActiveRecord::SpawnMethods

Methods to remove e.g. order or conditions from an existing scope chain.

Rspec shared example group error: ensure_shared_example_group_name_not_taken

Never name your shared example group *_spec.rb. Otherwise rspec will try to load your example group as a spec and you will get the error above.

Mock the browser time or time zone in Selenium features

In Selenium features the server and client are running in separate processes. Therefore when mocking time with a tool like Timecop, the browser controlled by Selenium will still see the unmocked system time.

SinonJS allows you to mock the client's time by monkey-patching into Javascript core classes.
We use SinonJS in combination with the Timecop gem to synchronize the local browser time to the time currently mocked with Timecop.

To integrate those two, we include and act…

Unfinished

STI and LoadError (Expected script/../config/../app/models/sub_model.rb to define SubModel) Exception

I was using single table inheritance lately and experienced the problem that a parent class did not know about its subclasses in development mode. The inheritance structure was like follows:

class Event < ActiveRecord::Base
end

class GlobalEvent < Event
end

class NewRegistrationEvent < GlobalEvent
end

class ConsultingRequestEvent < GlobalEvent
end

When I tried to load all global events in a controller, all I recieved by GlobalEvent.all was an empty set even though there were some new registr…

External content

Test your CSS rendering output with GreenOnion

No one wants to cry over regression issues in views; does testing HTML and CSS have to be such a back and forth between designers and devs? Why is it that the rest of the stack can have TDD and BDD but not the presentation layer? Well, GreenOnion is here to help you get the same results on testing front-end styling that you've enjoyed in your unit and integration tests up to now.
GreenOnion records 'skins', which are snapshots of the current state of a view (or any page that a browser can navigate to). The first time that it is run on a view…

SSL certificate problem, when trying to install the libyaml package

I was experiencing the following problem:

 It seems your ruby installation is missing psych (for YAML output). 
 To eliminate this warning, please install libyaml and reinstall your ruby

So I tried to install the libyaml package via:

rvm pkg install libyaml

This is when I experienced the SSL certification problem mentioned above. This happens when your RVM certificates have expired. You can fix this by updating them via:

 rvm get stable

After doing that curl could verify the SSL certificate and I w…

Understanding the Selenium error "Modal Dialog Present"

So your Cucumber feature sometimes dies with this exception:

Modal Dialog Present (Selenium::WebDriver::Error::UnhandledAlertError)

As a seasoned Selenium vetaran you are used to misleading error messages. Hence you might be surprised that the reason for this particular error is that there is actually a modal dialog present and preventing Selenium from executing commands like click or page.have_css?.

How your code triggers this issue

The reason why a dialog is shown is somewhat fucked …

MySQL: Can I speed up LIKE queries by adding an index?

For string columns, MySQL indexes the left side of a string. That means an index can speed a like query that has a wildcard on the right side:

SELECT * FROM foo WHERE field LIKE "bar%" # will be faster with an index

It can not speed up a query that has a variable left side:

SELECT * FROM foo WHERE field LIKE "%bar%" # will not be faster with an index

That also means if you use the ancestry gem you should index your ancestry column if you use scopes like descendants or `su…

Why stubbing on associated records does not always work as expected

Be careful when stubbing out attributes on records that are defined by associations. Nothing is as it seems to be.

The associated record has its own universe of things; when delegating calls to it, you ca not stub methods on the associated record and expect them to be around. That is a general issue with this pattern/approach.

What's happening?

Consider these classes:

class Post < ActiveRecord::Base
  belongs_to :thread
  
  def thread_title
    thread.title
  end
end

class Thread < Acti...

Asset pipeline: Reasons why your stylesheet is empty

It might be one of the following:

  • You are looking at a manifest file (like application.css) which is always empty during development
  • Your Sass file has a syntax error it did not handle properly

ReText

ReText is a cross-platform WYSIWYG-ish Markdown editor.

Toggle editor and preview layout with Ctrl+E.\
Press Ctrl+L to split the window for a live preview.

I use it to copy Pivotal Tracker story descriptions over, switch to the preview and have it as a small always-on-top window in a corner of one of my screens.


On Ubuntu, you can use a PPA to install:

sudo add-apt-repository ppa:mitya57/ppa
sudo apt-get update
sudo apt-get install retext

How to fix: Firefox uses incorrect fonts on all webpages, regardless of their CSS

If you encounter a Firefox that does not care about your font settings but always uses specific fonts, you can fix that. Usually this should not happen, as it's not a default setting:

  1. Open up the Preferences.
  2. Switch to "Content".
  3. In the "Fonts & Colors" section, click the "Advanced…" button.
  4. Tick "Allow pages to choose their own fonts, instead of my selection above".
  5. Confirm by pressing "OK".
External content

Rails, callbacks, workers, and the race you never expected to lose « Logical Friday

How delayed jobs can make your after_save callbacks execute before the record is saved.

RubyMine: Accessing views and partials from controllers

You can quickly access views that belong to a controller by using the tiny "page with arrow" icon in the gutter: icon

Access a method's view file

Click the icon next to the method definition in the controller.

If a view file does not yet exist, RubyMine will prompt you for its filename.

All views & partials associated to a controller

For a list of all views and partials that belong to the current …

External content

Git Landscaping

I recently worked on a project with 60+ old feature branches. Most of them had been merged into master and were subsequently abandoned. We decided we wanted to clean up a bit, and git made that easy.

External content

Firebug tip: Log DOM Events

This Firebug feature is called simply Log Events and allows developers to log DOM events into the Console panel.

All you need to do is right click on an element in the HTML panel, pick Log Events from the context menu and switch to the Console panel to see the logs in action.

External content

Twitter Bootstrap: Base CSS

Explanation of the "bootstrap 2" base CSS.

Contains information about:

  • Typography
  • Code
  • Tables
  • Forms
  • Buttons
  • Icons
View
3198 cards