Archive › Rails

Rails 2.1 Label

A label method is introduced in Rails 2.1. The following code: [sourcecode language="html"] < % form_for (@post) do |f| %> < %= f.label :title %> #Code truncated for clarity < % end %> [/sourcecode] Would generate the following HTML: [sourcecode language="html"] Title [/sourcecode] If your label contains a css class and if you need another [...]

Comments ( 0 )

Netbeans

I use Netbeans6.1 when developing in Rails. The thing I like most about it is that I can easily read the docs from a certain method in my code. I just press Ctrl + hover my mouse to that method and walla, the docs appears in my IDE. I can also do that when placing [...]

Comments ( 2 )

Rails 2.1 script/dbconsole

In Rails 2.1, you have a new script/dbconsole Instead of accessing your MySQL database with mysql -u <username> -p You can instead do script/dbconsole and if you database has a password, just do script/dbconsole -p All this works provided that you have the correct database.yml settings.

Comments ( 0 )

Global Email Settings in Rails

I was running the functional test and didn’t realize it was sending actual emails from my data fixtures. However, I did learn how to globally set the email settings so not to send the emails out during tests. If you want to use this, create a file called global_email_settings.rb (or whatever you want to name [...]

Comments ( 1 )

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 [...]

Comments ( 0 )

to_proc or not to_proc

Instead of writing this [sourcecode language='ruby'] Profile.find(:all).collect{ |x| x.email } [/sourcecode] I could write this using Rails’ Symbol#to_proc [sourcecode language='ruby'] Profile.find(:all).collect(&:email) [/sourcecode] Nice.

Comments ( 0 )

User filter_parameter_logging for 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 [sourcecode language="ruby"] Parameters:{“commit”=>”Log in”, “action”=>”create”,”controller”=>”sessions”, “password”=>”password123″,”login”=>”foobar”} [/sourcecode] I know, this looks like a trivial matter but imagine anyone having access to our [...]

Comments ( 0 )

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 [...]

Comments ( 0 )