.script/console and other ruby on rails wonders
I’m relatively new to this whole Ruby on Rails scene. You might say I’m a bit of a n00b. But it’s not just Ruby on Rails I’m new to it’s frameworks in general and OO languages as well. Which is not a good combo. But that’s a topic for another post. Right now I’d like to share something I learned early on Saturday morning as I contemplated breaking my laptop on my face because my form would’nt update my database. Fortunately I was able to take a break before I did anything irrational and hoped on to the #rubyonrails IRC channel. A big shoutout to them! I learned a lot in a short amount of time and here are a couple of them.
I’ll start with the best and go down from there. In the midst of my troubleshooting woes I was introduced to .script/console by a member of the aformentioned IRC channel. This is an invaluable tool in the Ruby on Rails framework. In a nutshell it’s a ruby console with access to your projects Classes and Database connections. You basically run ruby commands using stuff in your app. Holy freakin’ awesome! It’s a lot more responsive in terms of immediate feedback and you don’t have to worry about the hassle of views and other junk. Great debugging and testing tool. I know I should have known about this long ago, but we all have to learn at some point.
tail -f log/development.log
This one is awesome as well, but on a different level. After spending near an hour wading through the development.log which was packed full of routing errors (which makes me wonder about the sanity of Locomotive) I was clued into this awesomeness. Turns out if you run this little line in a Terminal window in the root of your application you can see real time the log outputs, which is super handy in conjunction with the above .script/console command (a little dual terminal window action) because it becomes all the more verbose. Which is awesome when you’re trying to pinpoint a hidden issue.