Posts by Jason Noble:
Rubymine print current line
One way of debugging your ruby scripts is to print out the value of variables in different sections of your code.
Rubymine has a feature called live templates that allows you to type a short command and have RubyMine extract it in to full blown code. Some built in shortcuts exist, such as def (creates a method), desc (create a RSpec test), it (RSpec test), etc.
To create your own, go to RubyMine -> Preferences -> Live Templates. Click one of the existing templates and hit Copy.
I named mine pl (Put Line Number) and put the following content in:
puts “#{__FILE__:#{__LINE__}”
Now when I’m typing code, I can hit the following:
pl<TAB>
p “Hello”
And it will print out the following:
/Users/jasonn/source/project/junk.rb:1
“Hello”
I’ve found this helpful for tracking down where a specific print statement is located.
Updated: Rails3 Custom Environment Variables
A while back, I wrote a blog post on adding custom environment variables to Rails3. This has gotten much easier with a change made by Jose Valim back in March. The change allows you to create your own custom configuration variables like so: [ruby] # config/environments/development.rb Demo::Application.configure do […] config.json_url = "http://www.domain.com" […] end [/ruby] […]
Visiting Pivotal Labs in Boulder, CO
I recently had the opportunity to visit Boulder, CO (Wiki, Map). The reason for my visit was to visit the Pivotal Labs office and spend a day pairing with them. One of the cool/interesting features of the Pivotal office is that the company provides breakfast in the morning. I walked into the office to find […]
Rails3 Custom Environment Variables
I recently saw a question on Stack Overflow regarding custom variables that have different values based on which environment you are running for Rails. It turns out it’s very easy to accomplish. [ruby] # config/initializers/configuration.rb class Configuration class << self attr_accessor :json_url end end [/ruby] This gives you access to a Rails variable called Configuration.json_url. […]
Pushing Depot to Heroku
I’m working my way through Agile Web Development with Rails, 4th edition by Sam Ruby. I just finished up with Chapter 6: Creating the Application. It’s working fine on my machine, but I wanted to push it to Heroku. Here’s how I did it: [plain] echo "gem ‘heroku’" >> Gemfile bundle install git init git […]
Playing around with Conductor by DHH
A while back, I saw that DHH had published a rails engine called Conductor. I added it to my list of things to look at and tonight, I got some time to take a look. I’m using RVM with 1.9.2p0 and rails 3.0.1. [plain] rails new conductor && cd conductor [/plain] I edited my Gemfile […]
Straight HTML/CSS for a change of pace
I recently worked on a personal project involving HTML and CSS. My wife’s family is trying to sell a 52 acre parcel of land in Noxon, MT. They wanted a website that showed the property better than the real estate agent was able to provide (short summary, only one photo). The site I came up […]
Cruise control.rb refusing to build a project
I ran into an interesting problem at work today. I had a cruise control project that would not build the project after a commit was made. Other projects in CruiseControl.rb were working properly. Here’s the steps I used to debug: Login to your Cruise Control box and cd to $BUILD_DIR/projects/$PROJ_NAME/work Run the following command. This […]
Testing syntax highlighting
[java] public class HelloBlogger { public static void main(String [] args) { System.out.println("Hello Blogger!!"); } } [/java]
rspec file is newer than
My pair and I were working on implementing LessCSS at work this week and we ran into an interesting problem. We wanted to write RSpec tests that would figure out if the .less file was newer than the .css file, and if so provide a good error message. We discussed this with Hosh and he […]