How to pass variable to partials in Rails

Leave a comment

Define your partial


<ul class="pager">
  <li class="previous">
    <%= link_to "&larr; Previous".html_safe, prev_url  %>
  <li class="next">
    <%= link_to "Next &rarr;".html_safe, next_url  %>

You can see here prev_url and next_url are variables that I want to pass values to when I call this partial.

Then call it like this:

          <%= render 'shared/next_prev_nav', :prev_url => "", :next_url => "" %>

How to specify controller and action in rails form

Leave a comment

Here’s a simple example of how to create a form specifying the controller action method in the form request.



  match '/load',      to: 'load#new',           via: 'get'
  match '/load',      to: 'load#create',        via: 'post'


<%= form_tag({controller: "load", action: "new"}, method: "post") do %>
    <%= label_tag(:q, "Search for:") %>
    <%= text_field_tag(:q) %>
    <%= submit_tag("Search") %>
<% end %>


class LoadController < ApplicationController

  def new


  def create
    raise "foo"


Here I am just purposely raising an exception to see if I hit the create method.

Running it looks like this


You can see and pull the request params at the bottom like this:

  def create
    query = params[:q]

How to cut a circle in half with illustrator

Leave a comment

Say you want a semi-circle and you want to split it in half.


Here’s how you do it.

Draw your circle


Select the knife tool


Holding down the ‘Option’ key on your Mac, with your shape selected, drag the knife across the circle in a straight line.


Now you should be able to drag one shape away from the other. Except this doesn’t always work for me (sometimes the whole shape wants to move).

In that case bring up the ‘Path Finder’ Window and with your newly cut shape highlighted select the ‘Minus Front’ option. That should cut away the bottom half of your shape.


And Voila! Half a circle with a nice contour around all the edges.


Links that help

Drawing the Human Face

Leave a comment

Human faces are great at teaching beginners the importance of proportionality when learning how to draw.

What makes the topic so fascinating, is learning that our brain is changing incoming visual signals to fit our preconceived conceptions.

For example, would you believe all four of these men below are of the same size?


Or how about this table. Does the surface of one look larger than the other?


As strange as this may same, the x4 men all all the same size, and the tabletop surfaces are of equal size too!

This phenomenon is called “visual constancy” and it throws us off when drawing.

The chopped off skull and misplaced ear

Two critical relationships beginners seem to struggle with is the location of the eyes, and the location of the ear in profile view.

Look at this early picture titled ‘Carpenter’ by Vincent van Gogh.


Early on in his career, van Gogh struggled with problems of proportion. Like most of us, he put the eyes too high, and the ears too far forward.

Two years later, you can see how van Gogh had solved his problems with this much more proportionally correct picture titled ‘Old Man Reading’.


The eyes on the human head are actually located ½ way down the face.


The the ears on the profile view are the same distance from the eye level to the chin.

Eye level to chin equals back of the eye to back of ear.

Once you grasp these non-refutable dimensions, drawing human faces becomes much easier. Here is an exercise where Betty asks her students to copy this picture called ‘Mme. Pierre Gautreau’ by John Singer Sargent.


The picture looks deceptively simple, but mastering and getting down the proportions is critical.

Here is my attempt.


It’s not great. It’s also not bad. I tried really hard to get the eyes, lips, and ears in the right place. But you can also see where I didn’t quite get the neck width right, or the mouth and chin (maybe this is a picture of her mother).

Anyways, the important thing to note is that there are critical maxims and rules of thumb to master if one is going to draw the human face correctly.

Back to the drawing board :)


How to add curves to a straight line in illustrator

Leave a comment

Say you have a shape that you want to add some curves to.


Here I want to add some curves to the bottom straight line (it’s the outline of a super hero cape). Here’s how you do it.

1. Add some anchor points.

Select your shape, find the straight line you want to add a curve to, and add anchor points where you want the curves to appear.

First select the ‘Add anchor point tool’


Then add your anchor points by clicking on the line where you want them to appear (more dots should appear on the line).


See where the straight line used to have no anchor points between the ends. Now it has two.

2. Add some curve.

Select your direction tool (shortcut – A)


then select the anchor point(s) you just added, and pull them in the direction you want your line to curve.


See how that bent our line? Next let’s smooth it out.

3. Smooth it out.

If you want jagged lines, you are done. If you want these to be curved, we need to convert these anchor points to ‘smooth’.

Using the same selector tool (short cut – A), select the anchor point you want to convert and then go to the top Illustrator and select ‘Convert Selector Points to Smooth’.


That should now smooth out your line and give it some nice curve.

Happy drawing!

Links that help

How to draw a line with arrowheads at both ends adobe illustrator

Leave a comment

1. Draw your line using the pen tool.


2. Open the Window > Stroke panel.


If you don’t see the arrowhead section try toggling the ‘Show Options’ by hitting the little arrow with squiggly lines.



3. Add your arrowheads.



How Artists Give Depth – Perceiving Relationships

Leave a comment

Look at this drawing. There is a lot going on.


Notice how horizontal edges that fall on the horizon are flat?
Also notice how any horizontal edges above the horizon converge down?
And how horizontal edges below the horizon converge up?

“Art is a lie that makes us realize the truth.” – Pablo Picasso, 1923

“Point of view is worth 80 points of IQ.” – Alan Kay, Computer Scientist

These concepts are part of the perspective paradox. We know alls sides of a square have equal length sides, yet if we want to draw one with perspective, that ‘rule’ needs to be broken.

Art has concepts that helps artists deal with perspective. One of them is vanishing points.

Vanishing Points

The vanishing point is that level on the horizon the artists eventually sees all lines of perspective converging. It’s that classic road fading off into the horizon.

When we do this a couple of things happen.

  1. Horizontal edges that are below the horizon converge up.
  2. Horizontal edge below converge down.
  3. And those on the horizon are flat.

Get this wrong in your drawing and things are going to look weird. So it’s a maxim artists use to maintain perspective.

Here’s a building I happen to be sitting inside.


Can you see the vanishing point? Here is me trying to capture it.


If an artist were doing this for real, they would be way more careful than I am (I just eyeballed it). But you can see it. It’s there in every picture with depth.

The trick is identifying the vanishing points in your drawings, respecting them, and then drawing everything else in a way that respects them.

Easier said than done. Here is me trying to fill in some detail.


It’s OK (in that I picked a vanishing point). But you can see how bad it looks if you get the horizontal edges wrong.


Here’s a beautiful drawing (with lots of challenging perspective lines) by Alex Eben Meyer.


Anyways, as a software programmer learning to draw, what I take away from all this is there are rules of thumb, design patterns, and maxims in art, just like there are in software and anything else.

I enjoy learning about these because it helps me see the world differently, in ways I couldn’t before.

Vanishing lines are neat. You need to respect them, else your drawing will come out all funny and the human eye will reject.

More drawing posts:
How Artists Draw the Hard Parts – Negative Spaces
Modified Contour Drawing Exercise
Drawing on the right side of the brain
Three exercises to get you going
Vases and faces
Drawing upside down
Use contour drawing to see things differently

Betty’s excellent book Drawing on the Right Side of the Brain.

Older Entries


Get every new post delivered to your Inbox.

Join 302 other followers

%d bloggers like this: