Tim Reistetter
Tim Reistetter

Reputation: 839

What does this ruby/rails code mean?

I am going through this tutorial: http://blog.assimov.net/blog/2011/04/03/multi-file-upload-with-uploadify-and--carrierwave-on-rails-3/

One of the lines of code is:

@photo = params[:id] ? @property.photos.find(params[:id]) : @property.photos.build(params[:photo])

I don't understand what the ? and : do in that line, or what it is supposed to accomplish.

Upvotes: 0

Views: 99

Answers (1)

nckturner
nckturner

Reputation: 1266

Take a look at this: :? ternary operator

Upvotes: 5

Related Questions