How To Write "Macros" in Ruby

April 14, 2015

In Rails you use class-level declarations such as has_many, belongs_to, and other so-called "macros" all the time. Look familiar?

class Movie < ActiveRecord::Base
  has_many :reviews
end

class Project < ActiveRecord::Base
  has_many :tasks
end

Folks new to Rails (and Ruby) often assume these declarations are a magical aspect of Rails. In fact, there is no magic—it's just Ruby code. Indeed, Ruby makes programming in this declarative style easier than you might think.

In this short video tutorial we recreate a simplified version of the has_many declaration from scratch so you understand how to apply this same powerful technique in your own Ruby code!

Thanks for watching and please feel free to leave a comment below!

P.S. If you're using Rails and it feels too magical or you struggle with Ruby concepts, check out our online Ruby course. You can start this course for free today and begin learning how to design object-oriented programs the Ruby way.

How to Create, Preview, and Send Email From Your Rails App

March 31, 2015

Rails 4.2 includes some handy new features in Action Mailer. In this brief tutorial, we'll walk through how to send emails step-by-step using these new features!

For transactional email, consider using a service such as:

For newsletters, announcements, and bulk email, consider using a service such as:

For more details, check out Action Mailer Basics and the full mail method documentation.

If you're new to Rails in general, check out our Ruby on Rails: Level I online course. You can start this course for free today and begin learning how to design full-featured Rails apps with confidence. Then take your Rails skills to the next level in our Level II course.

Thanks for watching and please feel free to leave a comment below!

How To Add jQuery and Ajax To Your Rails App

March 18, 2015

Wondering how to get started adding JavaScript to your Rails app? In this brief tutorial, we'll look at how to add some effects with jQuery and send Ajax requests in a Rails 4 app!

If any of the Rails concepts in this tutorial threw you for a loop—such as forms, partials, redirects, or other Rails conventions—check out our Ruby on Rails: Level I online course. You can start this course for free today and begin learning how to design Rails apps with confidence.

If you need a bit of help understanding Ruby blocks such as those we used with the respond_to method, give our Mastering Ruby Blocks & Iterators online course a look-see. Blocks are used pervasively in well-designed Ruby and Rails apps, and this short course will help you become a blocks master.

Thanks for watching and please feel free to leave a comment below!

How you can "feel newly empowered", too!

February 19, 2015

Thom
I really thought I had a good grasp on Ruby blocks, but I was mistaken. Thanks for taking the time to dig into blocks and iterators at this level of detail and thus saving me the time of exploring and uncovering these techniques and patterns on my own. I am NOW quite confident about my understanding of blocks, and mastery over them. I suddenly feel newly empowered!” — Thom Parkin

I love that Thom uses the word “empowered” to describe how he felt after our Mastering Ruby Blocks & Iterators course. That's exactly how I felt when I learned how to really use blocks in my own code. I'm not talking about how to write a block. Sure, understanding the basic block syntax and style is important and it's where we start in our course (free video). But using blocks effectively is about so much more than curly braces, vertical bars, and syntactic sugar.

The real sweet spot is when you start designing your own code to take advantage of the power of blocks. Indeed, well-designed Ruby code uses blocks to elegantly solve common and recurring problems, including: ...

[Continue Reading…]

"All the diagrams in your courses are total awesome-sauce!"

February 05, 2015

How do you learn new concepts best? I'm both a visual learner and a visual explainer. When it comes to learning something new, I'm a first-rate doodler. My brain engages more quickly when I can pick up a pen and draw circles, lines, squares, and all manner of arrows on a piece of paper.

The opposite is true too. When I try to explain something, I have a hard time conveying the topic with mere words. I'm compelled to draw it out. Mike, in a similar way, is compelled to code it out, as a way of explaining the concept.

MVC Diagram

It should come as no surprise then that our courses include lots of code examples and a bunch of diagrams! We don't hesitate to use squares, arrows, buttons, highlights, and whatever else it takes to help explain new concepts visually.

So we're especially delighted when we hear from our alumni that these diagrams and sketches help them really understand new Ruby and Rails concepts: ...

[Continue Reading…]

Daily course plans to help you learn Ruby or Rails in the New Year

January 19, 2015

Do you have a goal to finish your online Ruby and Rails courses soon? We know it's hard to hold fast to New Year’s resolutions once the familiar whirlwind kicks up. It can all be a bit dizzying!

Grab ahold of our daily course plans to help you stop the spinning and chart a realistic, incremental path for meeting your learning goals.

Download a plan, print it, and use your favorite-colored Sharpie to cross off the days. Each day you'll add one more facet of Ruby or Rails to your repertoire and make steady progress toward completing the course and meeting your goal. You can do this!

Guru's Reviews

January 13, 2015

"I am not sure if Pragmatic Studio guys have a 'PS I love you' sticker floating around but I would definitely put it up."

That comment on Guruprasad’s (Guru's) blog totally made us smile. Back in our early days, we did in fact have stickers!

We used to hand out these bumper stickers at the end of every public Rails courses. The stickers ended up on more laptops than actual bumpers, but by pairing them with our course evaluations as a little incentive for completing the form, we got invaluable feedback from our students.

In the case of Guru, he made up his own suggestion for a sticker and gave us a bunch of feedback! Check out his blog posts to hear more about his experience using our online courses to learn Ruby and Rails:...

[Continue Reading…]

Merry Christmas, Everyone!

December 23, 2014

Getting Started With Elm

December 19, 2014

Around this time of year I tend to go looking for something new to learn in the spare moments between holiday activities. It's a way of stepping back and getting a different perspective. This year the Elm language caught my eye. So on a whim one afternoon I cracked open the laptop and starting writing some Elm code, not really expecting my interest to outlast a log on the fire.

Well, it's been a week now and I'm still having fun goofing with Elm. Turns out this journey has been an unexpected gateway into functional programming, but with a graphical twist. I think the graphical part has been the key for me. That or the steady intake of sweets that keep finding their way to my desk. In any event, the whole experience has been so enjoyable and enlightening that I couldn't help but share.

If you've been wanting to try FP, I'd encourage you to give Elm a whirl! Here's how I got started...

Try Elm

The easiest way to get started with a quick win is by using the interactive online editor. Here's every newbie's favorite first program, Elm style:

import Text (..)

main = asText "Howdy world!"

Type that code in the left-hand pane of the online editor, hit the "Compile" button (or use the keyboard shortcut CTRL-RETURN), and the output magically appears in the right-hand pane. For a peek behind the scenes, view the source in the right-hand pane and you'll see that the Elm code got compiled to a potent mix of HTML, CSS, and JavaScript.

Cool! So that works, but why? ...

[Continue Reading…]

Give the Gift of Learning

December 16, 2014

Got a developer on your gift-giving list? Give 'em a gift that lasts well after the holiday decorations have come down—the gift of practical can-do know-how. Our online, self-paced training courses make for awesome gifts and we'll even do the wrapping for you.

It's quick and easy to gift our courses. Just head on over to our course catalog, toss an online course or two into your cart, and enter the name and e-mail of the person to whom you're gifting the course.

Once the order is placed, our Ruby-powered elves will send your special developer an e-mail with instructions for accessing their online course(s). It's a great way for you to play secret Santa, or you can follow-up with a cheery note. And as a bonus, your developer automatically gets alumni status which means they'll save 25% on their next course. As they say, it's a gift that keeps on giving!

Need help picking a course? No problem. If your developer is planning to make a transition to Ruby in the new year, he'll love getting up to speed quickly in the Ruby Programming course. Or help take her existing Ruby skills up a notch with Mastering Ruby Blocks & Iterators. Is he dreaming of developing a web app? If so, he'll go from idea to deployment and beyond with Ruby on Rails: Level I and Ruby on Rails: Level II. Or if you want to splurge a little while taking advantage of combo discounts, put her on a continuous learning path with two or more courses!

Hope you find these ideas helpful when loading up your sleigh this season.

Merry Christmas to all!

« Older Posts