Updated : August 2011 to work with Factory Girl 2.0.5
It’s been annoying me for some time that when I hit reload! in the Rails console my factories stop working, or point to the wrong class. This wasn’t a real issue until I started using Devise.
Devise uses a mapping between classes and routes, so when a factory built object comes through to Devise after a console reload, or a class redefinition then it will fail. This is commonly the case in development and test environments.
I sat down with a colleague today (thanks Darcy) and we found the appropriate place to reload Factories to have it all work.
This is the code we put into my application.rb :
ActionDispatch::Callbacks.after do
# Reload the factories
return unless (Rails.env.development? || Rails.env.test?)
unless FactoryGirl.factories.blank? # first init will load factories, this should only run on subsequent reloads
FactoryGirl.factories.clear
FactoryGirl.find_definitions
end
end
After that everything just worked and I can hit reload! in the console without any issue.
2011 is already in full swing, so here’s a peek into some of the work we’ve been involved with so far:
We’re working with the Climate Watch project, first launching their site and now performing a series of modifications to bring more improvements to the service.
We’re expanding the Carboodle platform to sell catalogued new cars, as well as existing second hand stock.
We partnered with the Green Network and look forward to rolling out their new website in the coming weeks.
We have livened up the Ruby on Rails section of the Sitepoint blog, with a new series of posts.
We dedicated some time to our own new website, and look forward to launching that in February.
Here’s hoping February brings just as much action for our team!
There was a question that was asked on our IRC channel today about how to get all the associations for an Activerecord model. I’m assuming it was to do some debugging or something, in any case I did a bit of digging around in the Rails docs and it turns out the answer isn’t that hard.
Doing something like :
Model.reflect_on_all_associations
Will give you all the associations for that model, it’s pretty dirty though and so an easy way to tidy it up is :
As 2011 approaches, I decided to look back on a few of the great organisations we have worked with in the last 12 months. We’ve always had a soft spot for building web sites and web applications that make a difference to real people, as opposed to just solving a business need.
Here’s an overview of some of these projects from 2010.
WA Special Needs Children’s Christmas party – Cash donation
Partnerships / Organisations helped
Independent Living Centre of WA – Built and maintained web systems to help them book more appointments and serve more people in the community. Also rebuilt their website to be accessible, more useful to their audience and added an equipment supplier search feature.
Independent Living Centres Australia – Current development of the new website and the national supplier database, integrating seven state-based databases into one.
At The Frontier Group we like to help out deserving charities as often as we can either through partnering, work, or sponsorship.
Drop in the Bucket is an organisation that has found its way to us and we are encouraging all our clients and friends to donate through the widget on our special Donate to Drop in the Bucket donation page.
You can read up on Drop in the Bucket below, or at their website: Drop in the Bucket. Our aim (along with Resonate Social Media) is to raise $10,000 to build two wells by March 31 2011.
Drop in the Bucket
MISSION
Drop In The Bucket is dedicated to improving the health and safety of children in Africa by providing clean water wells and sanitation systems to African schools, particularly those in post-conflict settings. We align ourselves with experienced engineers, innovators and economists who have a vast knowledge of African culture and water solutions so that we can meet the unique challenges associated with the developing world’s water crisis.
The cornerstone of our approach is low overhead and minimal operating costs. We participate directly in every aspect of the process, from targeting each well location and personally working with and training community leaders, to actively helping set up and approve budgets, to diligently monitoring maintenance schedules and carefully tracking success rates. We place a very high value on sustainability and take proactive measures so the water wells and sanitation systems we install will provide benefits far into the future. Our hands-on involvement extends from the time water or sanitation needs are identified, through construction, and long after completion.
Drop In The Bucket provides everything from hand-dug shallow water wells, drilled boreholes, pumps and rainwater harvesting tanks, to an advanced sanitation system that includes the most environmentally responsible, permanent septic system available in rural Sub-Saharan Africa.
Our outreach teams are constantly working to find new ways to incorporate the beneficiaries into the process while our staff and consultants strive to continually develop innovations and improvements that will increase the scope and effectiveness of our efforts to provide clean water wells and sanitation systems to the children and their communities.
VISION
Drop In The Bucket believes we can help create a world in which children are safe, healthy, educated and free from fear. And we believe that the key to achieving those ends is clean water and sanitation.
In its 2000 Millennium Declaration, the United Nations created eight Millennium Development Goals to improve the human condition by 2015. One of the most important objectives in reaching these goals was to reduce, by half, the proportion of people without sustainable access to safe drinking water. The World Health Organization and UNICEF report that of the people still not using an improved source of drinking water in 2010, 37% live in one region of the globe: Sub-Saharan Africa (www.wssinfo.org).
Drop In The Bucket understands how central clean water and sanitation is to survival. We want to see an end to the 1.5 million preventable deaths that occur each year as a result of poor sanitation (www.unwater.org). We want to see the children of Sub-Saharan Africa have the same basic opportunities to live safe, healthy and happy lives as children in places where access to clean water and sanitation are available.
According to the World Water Assessment Programme (www.unesco.org) access to safe drinking water can make a significant contribution to:
(a) eradication of poverty;
(b) increased school attendance;
(c) reduction in diarrheal infections and malaria;
(d) decrease in maternal and child-mortality rates.
Drop In The Bucket wants to make a difference in the quality of life for children in the countries of Sub-Saharan Africa so they can reach their full potential and become healthy adults with the capacity to accomplish their goals and the opportunity to realize their dreams.