- << Eerste
- < Vorige
-
- 1
- 2
- Volgende >
- Laatste >>
Currently the posts are filtered by: Development
Reset this filter to see all posts.
Use Delayed Job with Devise mailers
In order to have Devise send its emails by background process application Delayed Job just include one line of code after your Devise declaration in your user model. Devise uses one method for all mailers. So all modules make use of it, including extensions like DeviseInvitable (check their code for this method!).
- Code: Select all
-
class User < ActiveRecord::Base devise :database_authenticatable, :recoverable, :lockable, :trackable, :timeoutable, :invitable # Use delayed job to send emails from Devise and DeviseInvitable handle_asynchronously :send_devise_notification, :queue => 'devise' end
Tested on Rails 3.2.13 with Devise 2.2.4 and Delayed Job 3.0.5
Using SimpleCov with FactoryGirl
FactoryGirl is a great replacement for your Ruby-on-rails fixtures. They offer more flexibility for generating stubs and mack-ups for your automated testing.
SimpleCov is the test coverage tool for Ruby 1.9.x (Use RCov for Ruby 1.8.x).
Using both in conjunction requires two extra lines in your test/test_helper.rb file not covered by any documentation. This will prevent you from getting messages like "Factory not registered: " or "uninitialized constant Test::Unit::TestCase::FactoryGirl (NameError)".
My test_helper.rb file looks like:
- Code: Select all
-
require 'simplecov' SimpleCov.start 'rails' ENV["RAILS_ENV"] = "test" require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' # The following two lines of code will reinitialize Factorygirl: require 'factory_girl' FactoryGirl.reload class ActiveSupport::TestCase ... end
Fix jQuery .replaceWith() method to perform in IE8
This article applies to jQuery 1.4.4
The jQuery .replaceWith() method replaces a DOM-element and all of its children by another DOM-element. This function is ideal for use in Ajax applications.
The .replaceWith() method however internally uses the jQuery .remove() method which in Internet Explorer can be dramatically slow. There is a tric however to improve this performance radically by emptying the DOM-element first before removing it.
It enhanced my performance in IE at least 10 times!
Here's the line:
jQuery(selector).empty().replaceWith(newContent);
Show jQuery tabs promptly
jQuery tabs are just fabulous!
But if you have a lot of content then you might see your tabs being built up when jQuery applies them.
Here's the solution. Just hide the tabs HTML element initially:
<div id="my_tabs" style="display:none;">
Then use the following jQuery Tabs Event to display them when they are ready:
$('#my_tabs').tabs({
show: function(event, ui)
{jQ(event.target).not(':visible').show();}
});
By using jQuery's .not(:visible) filter method show() is executed only once.
HTML5 helpers for Rails 2.3.x
Eager on using HTML5 in your Rails projects without upgrading to Rails 3?
For those I've ported the HTML5 FormHelpers and FormTagHelpers from Rails 3 back to Rails 2.3.x. So you can now use:
<%= f.email_field(:email) %>
<%= email_field_tag(:user, @user.email) %>
All helpers are Rails 3 compliant so after updating to Rails 3 just remove the plugin.