Showing posts with label Ruby on Rails. Show all posts
Showing posts with label Ruby on Rails. Show all posts

Wednesday, May 28, 2008

Rails training, anyone?

I got a little lazy (well, a lot really... ) so i decided that i didn't want to study Rails by reading, but by watching a video with a popcorn in hand (really hard to get good popcorn these days)

searching through the web for video tutorials, I came across this set of videos from guys at UC Berkeley RAD Lab... Never been to UCB, but I hear its a beaut... my kudos to the guys at UCB RAD...

the video filesizes are large... I nodded off waiting for it to stream... so you might wanna have a firefox extension do the downloading for you before you view them... here's one. If you're using IE... again, seriously?

anywho, check it out! i think it's RAD! haha! (although i haven't even gotten to the end of one yet, so no guarantees)

we'll post some video tutorials up in the future - when we actually have time to kill... but we will... promise...

Thursday, May 22, 2008

to_proc or not to proc

Instead of writing this


Profile.find(:all).collect{ |x| x.email }


I could write this using Rails' Symbol#to_proc


Profile.find(:all).collect(&:email)


Nice.

Wednesday, May 21, 2008

Use filter_parameter_logging for your password

This morning while I was looking at some codes, I've found something interesting. When I login, I looked at the logs and I could see clearly the password that I'd just entered.

Example


Parameters: {"commit"=>"Log in", "action"=>"create", "controller"=>"sessions", "password"=>"password123", "login"=>"foobar"}


I know, this looks like a trivial matter but imagine anyone having access to our server looking at our production logs file. Passwords are left wide open for the whole world to see.

But no worries, just add this one liner in your application.rb


class ApplicationController < ActionController::Base
filter_parameter_logging "password"
end


Go back to your login form, fill in your login name and password and then submit.

Check out the logs and see the parameters hash.


Parameters: {"commit"=>"Log in", "action"=>"create", "controller"=>"sessions", "login"=>"foobar", "password"=>"[FILTERED]"}


Notice the hash key 'password'?

Sunday, May 11, 2008

Ruby Cheatsheet Part Two!

Finally, part 2 of the Ruby Cheatsheet is now complete! Click here to download the file from Scribd, which, by the way, is also an excellent site for lots of stuff... so kudos to the Scribd crew...

Part two gets you acquainted with the built-in stuff ruby provides to make your coding life easier and more fun (or confusing maybe?). Great help for you young apprentices who are looking forward to becoming Jedi Railers... (Nothing like geek speak to lighten up your day)

Now, about that project wall....

UPDATE: The combined version, part 1 and part 2 together, can be found here. I've made some improvements to the file to make it more readable - Acap

Tuesday, May 6, 2008

Ruby Syntax Cheatsheet

For all us Ruby on Rails newbies, it's really important to know Ruby, the language, before jumping into Rails. Learning Rails without knowing Ruby is like doing bike stunts without learning how to ride. Major pain bro...

Save yourselves from major cranial meltdown by learning Ruby syntax first. It shouldn't be too hard if you already know other programming languages. To help us with learning it, we created our own Ruby Syntax Cheatsheet

This is part 1 of the Ruby Syntax Cheatsheet we made to help us code in Ruby. It's based on the Ruby for Rails book by David Black. Highly recommended reading for all of us who aspire to become 'Jedi' Railers.... (hey, you can't make Jedi if you don't know the Force!). Click here to download the file