I don’t get it why some people write this
%(Unverified email address. Please check your email for your activation code.)
instead of this
“Unverified email address. Please check your email for your activation code.”
Is it that hard to put those double quote?
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 the cursor at that method and pressing Ctrl + \.
It also has code refactoring and code completion. Though I would still be careful on using the refactoring tool. Always check the preview first before you refactor it senseless. Code completion is a bliss but sometimes it can be PITA when you have bubbles coming out on auto mode each time you try to write a code. I have to repeatedly press Escape to make those bubbles disappear.
The most useful shortcut key IMHO is Ctrl + Shift + o. I can easily find the file that I need in my IDE. And the one thing I do frequently is format the code with Ctrl + Shift + F. Although sometimes it messes up my indented hashes.
Even though Netbeans has it own console and has all the right-click goodies when clicking the root project, I am still much more comfortable using my gnome terminal. I open multiple tabs of it when I’m coding. One for the script/server, another for script/console, sometimes for script/dbconsole, and another for those wonderful rake commands.
I also use Aloha for my Netbeans theme. It certainly gives me a textmate like theme. Though if I have the dough, I would buy myself a Macbook Pro and Textmate since all the cool kids uses them.
So yeah, Netbeans is cool and I hope that they can make it load things faster especially on the start-up.
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.
I need a tab navigation for some static display page. Stereotabs does the job nicely in my opinon.
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 it) and put it in your your config/initializers/ folder. Restart your server to get rolling.
begin
unless ENV['RAILS_ENV'] == 'test'
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => 'smtp.domain.com',
:port => 101,
:domain => 'domain.com',
:authentication => :plain,
:user_name => "",
:password => ""
}
end
end
This way, you don’t have to explicitly set your ActionMailer::Base.delivery_method = :test in each test setup.
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.
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’?
puts 'Hello World'