Week 12 Ruby/Rails Q&A

Well, I finally got Carrierwave running with some help from my friend Beverly. I was so focused on one area of the code that I forgot to install the RMagick gem. I had a few glitches with uploading because the commented out default in the image_uploader.rb says “process :scale => [200, 200]” which gave me an error on “scale” so I changed the wording to “process :resize_to_limit => [250, 250]” and it worked fine.

Q. What is “String Interpolation”?

A. String Interpolation is the process where ruby takes an input value and inserts it into a string of code. For example:

print “What’s your first name?”

first_name = gets.chomp

puts “My name is #{first_name}!”

“My name is YOUR NAME!”

When prompted for your first name, the second line of code sets “first_name” to whatever the input is, then the final output will use the value given for the first_name. If you are wondering what “gets.chomp” means exactly, “gets” is the method ruby uses for getting user input and “.chomp” removes the extra line generated by ruby after receiving the input. Using “chomp” is not mandatory to make things work, but it keeps things clean and is good practice.

Q. What resources do I like and use on a regular basis?

A. I listen to Ruby5 , which is a great 5 minute podcast. I recently joined Ruby Hangouts which is a group of ruby geeks that have hour or so long Hangouts and record them, usually featuring a well known developer in the industry. I just bought Eloquent Ruby, which has been highly recommended to me several times, I will be diving into that this week. I also use Codeschool, Treehouse, Codeacademy and Railscasts on a regular basis. If you have some favorite resources that I have not mentioned, please share them in the comments.

Have a question? email me at dennis@thecommongeek.com

If you found this useful, please share.