Check for existence before extending

Some rails components are optional. Don't assume they exist
and more over don't define them if they don't exist.