“Dropping” a mongohq database on Heroku

I’ve used inverted commas around the word ‘dropping’ because it doesn’t look like you can drop a mongohq database – what you can do however is drop all the collections in the database. I was doing this through the add-on interface in heroku but that got tired quickly, and after some googling it looked like the solution was to write a custom rake task and drop it into lib/tasks/; the file can be named anything with a ‘.rb’ extension. The code follows: [code language=”ruby”] namespace :mdb do desc ‘Drops all the collections for the database for the current Rails.env’ task :drop => :environment do if ENV[‘MONGOHQ_URL’] uri = URI.parse(ENV[‘MONGOHQ_URL’]) conn = Mongo::Connection.from_uri(ENV[‘MONGOHQ_URL’]) DB = conn.db(uri.path.gsub(/^\//, ”)) DB.collections.each do |collection| begin collection.drop rescue puts "Can’t drop: " + collection.name end end end end end [/code] Note that the exception handler isn’t perfect and essentially all I’m doing is skipping the system collections …

Read more

London Force.com Meetup – 20 October 2011

Yip it’s that time again and boy do we have some very cool speakers this time around. The gig is at Skillsmatter at 6.30pm on 20 October and is summarised in the info below. Please don’t forget to RSVP. Of course there will the be usual beers and pizza 😉 Hope to see you there! AMJAD KHAN ON FORCE.COM ERD USING SCHEMASPY Amjad Khan will give a talk to the SafesForce user group on How to Install and run SchemaSpy on any Salesforce Org to generate an ER diagram. More details… SIMON GOODYEAR ON MAKING BETTER USE OF INTERFACES ON THE FORCE.COM PLATFORM Simon Goodyear’s talk for the SalesForce user group will give a quick overview on what interfaces are, how you can make better use of them in APEX, and what we gain from doing so. More details… TESTING ON THE FORCE.COM PLATFORM Keir Bowden gives a talk for the SalesForce …

Read more

Ruby, Rails & RVM woes

I’ve had several issues over the past day pertaining to Ruby, Rails and RVM and all of them were caused by one silly thing. Problem 1: You can’t swap between Ruby versions using RVM If you can’t swap between Ruby versions that you know you’ve installed then you’ve probably installed something using “sudo”. It is highly recommended that you install & use RVM in the single user mode as this is easiest. If you do this then all the versions of Ruby etc. that you install will be installed in your home directory (usually ~/.rvm/) instead of system wide and this negates a whole bunch of complexities. Running this command will tell you which ruby executable you’re using: [code language=”bash”] which ruby [/code] If the executable is not sitting in your home directory e.g. it’s in /usr/local/bin then you’re in a spot of bother. The easiest way I’ve found to …

Read more

Salesforce: A better way to work with jQuery selectors and Visualforce Component Ids

I get very sad when discussing this particular topic. There are a variety of ways of get Visualforce component Ids and using them in JavaScript but all of them keep me awake at night. Srsly. A commenter on one of my posts got me thinking about how we can do this better and I’ve come up with a way that I think is great. Hopefully you’ll agree. This post means that my older posts here and here are now retired in favour of this method. If the world was on the brink of nuclear war with no clear path to peace what could you count on to save the day? Regular Expressions of course. If a meteor the size of Pluto was about to crash into Earth and Bruce Willis was too old to land on it and blow it up what could we count on to rid us of …

Read more

How many Salesforce Roles do you have in your Org?

I’ve worked with many Org instances in my career with salesforce.com and the Force.com Platform and was stunned by an Org that had a massive number of Roles, way beyond anything I’d ever seen before. This made me curious as to what other people were dealing with and I’m sure the result will be interesting. Note: If you work with several Orgs and you have a high tolerance for boredom please submit an answer for each 🙂 [polldaddy poll=5151467]

Salesforce: Debugging JavaScript

I love JavaScript, and working within the Force.com Platform I’m always finding new ways that it can be applied to business needs. I know this is the case for many developers out there but I’ve seen that their typical development process is: Develop the JS code Create bug Include calls to the alert() method to troubleshoot Iterate alert() is bad for debugging I’m sure this process sounds familiar to many of you, but do you know what, the alert() method is a very weak way of troubleshooting. I abandoned it years back because of poor features such as outputting object representations as ‘[object]’ or ‘[undefined]’ – which doesn’t give you a lot to go on. Meet console.log() Modern browsers have access to a library called ‘console‘ which offers a far richer experience, and without the annoying pop-ups. The console.log() method accepts any JavaScript type as a parameter and will always …

Read more

Salesforce & LinkedIn Developer API: 401 – Unauthorized

I’m not going to get into the boilerplate code you’ll need in order to get OAuth up and running as it’s pretty straight forward, but I did run into a peculiar issue which took me some time to narrow down. To reproduce these steps you’ll need to: Correctly setup OAuth between the Force.com Platform and LinkedIn Authorise access to your LinkedIn account Attempt to fetch a resource using an API endpoint such as: http://api.linkedin.com/v1/people/~/network/updates?scope=self When attempting to make the call out in step 3 you’ll get a “401 – Unauthorized” error. So to be clear OAuth is working perfectly but a call like this one will still result in the error. After some troubleshooting I noticed that some API endpoints didn’t result in the error e.g. http://api.linkedin.com/v1/people/id=abcdefg/network/updates?scope=self. At this point I realised the issue was probably the tilde (‘~’) character in the URI. Grasping at straws I manually replaced the tilde with …

Read more

Across the Pond with Jason Venable aka TehNrd

Today I start a series of posts that’ll appear here and on the Tquila blog. The series will be in the format of Q&A with some of the finest Salesforce.com and Force.com evangelists, admins and developers. I’m starting with Jason Venable aka TehNrd and I’ll let him introduce himself. Q: Tell me a bit about yourself. How long have you worked with the CRM vs the Force.com Platform? Were you always a developer? A: My name is Jason Venable. I am 27 years old. I live in Seattle, Washington, USA. Oh, wait, you want something more interesting, got it. I’ve been working with salesforce.com CRM for a little over 4 years. Three of these years have also been working with force.com. All of this time has been administering and developing for a large enterprise salesforce.com deployment at F5 Networks. A lot of what I do is merging the two worlds …

Read more