background preloader

Ruby

Facebook Twitter

Code School - TryRuby. Good show, my friend!

Code School - TryRuby

The join method took that list of reversed lines and put them together into a single string. (Sure, you could have also just used to_s.) Time for a quick review. Exclamation Points. Methods may have exclamation points in their name, which just means to impact the current data, rather than making a copy. Guess what? At this point, you may want to tinker with the poem a bit more. And now on to something new. String (Ruby 1.9.2) Str % arg → new_str click to toggle source Format—Uses str as a format specification, and returns the result of applying it to arg.

String (Ruby 1.9.2)

If the format specification contains more than one substitution, then arg must be an Array or Hash containing the values to be substituted. See Kernel::sprintf for details of the format string. static VALUE rb_str_format_m(VALUE str, VALUE arg) { volatile VALUE tmp = rb_check_array_type(arg); if (! NIL_P(tmp)) { return rb_str_format(RARRAY_LENINT(tmp), RARRAY_PTR(tmp), str); } return rb_str_format(1, &arg, str); } str * integer → new_str click to toggle source Copy—Returns a new String containing integer copies of the receiver. "Ho! Str + other_str → new_str click to toggle source Concatenation—Returns a new String containing other_str concatenated to str. "Hello from " + self.to_s str << integer → str click to toggle source str << obj → str Append—Concatenates the given object to str.

A = "hello "a << "world" a.concat(33) str[fixnum, fixnum] → new_str or nil produces: The Best Way to Learn Rails. I come from a PHP background, but these days, I'm a full-time Rails developer.

The Best Way to Learn Rails

The difficulty for most people who make the switch lies in the learning curve that’s involved. Once you've become proficient in a language or framework, switching to a new one feels like an unnecessary (and time-consuming) challenge. However, learning Ruby and Rails is actually pretty easy! It's an incredibly powerful framework, and has a huge community pushing it along. So that begs the question: what's the best way to learn Rails? This article details a full lesson plan that will get you up and running in no time! You might think learning Ruby is the most important step, and this is probably the part where everyone stops learning and just sticks with their current framework. Work through the Try Ruby exercises. The most recommended tool for dipping into Ruby's syntax is the Try Ruby website.

Once you’ve worked through these exercises a couple of times, you'll have a solid base. Great! Railscasts: A must! Introduction to Rails Screencast. Isn't it funny how most "introduction to Ruby on Rails" screencasts are overly simplistic, and rely on generators like scaffolding?

Introduction to Rails Screencast

The teacher typically follows up the tutorial by stating that most Rails developer don't use scaffolding generators. Well that's not much help then! I'd like to give you the tutorial I wish I had. Along the way, we'll also rely heavily on test-driven development to build a simple app. Create models and generatorsUse test-driven development to plan and test an application’s featuresWork with ActiveRecordAutotest with Guard Use Rspec and Capybara to simulate the user.Create partialsTake advantage of Flash notices…and plenty more If you watched the entire screencast, I hope you enjoyed it!