------ art_59065_16652241.1157072612612
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Recently while coding in rails, i had a column called in one of the tables
and hence was wrapped up by ActiveRecord.
Guess, what it broke entire of the code, because quote is a already defined
method somewhere in rails. I had trouble in finding out the root of the
problem.
Another example, as a newbie to ruby and rails I was using login_engine in
my rails code. I have a table called messages in my database. Now,
login_engine controller code is like this:
User.transaction(@user) do
@user.new_password rue
unless LoginEngine.config(:use_email_notification) and
LoginEngine.config(:confirm_account)
@user.verified
end
if @user.save
key user.generate_security_token
url rl_for(:action 'home', :user_id @user.id, :key key)
flash[:notice] Signup successful!'
if LoginEngine.config(:use_email_notification) and
LoginEngine.config(:confirm_account)
UserNotify.deliver_signup(@user, params[:user][:password], url)
flash[:notice] << ' Please check your registered email account
to verify your account registration and continue with the login.'
else
flash[:notice] << ' Please log in.'
end
redirect_to :action 'login'
end
end
Guess, what User.transaction was behaving oddly because it was throwing
warning "Messages already defined constant". The error was shown in web
server logs and hence again was a little difficult to track.
Now, how as a new guy to ruby and rails, how do i know , i shouldn't have a
column called quote and i shouldn't have a table called messages.
I am a Qt/C++ programmer also, and the namespace issue is mostly
non-existent there.First of all, its because all the Qt classes begin with Q
and hence you know.But Ruby library authors seems a little lax on this, and
open classes make the entire thing a little nifty and difficult to debug if
you are caught on the wrong foot.Either library authors should avoid
writting classes like Messages or ruby should give option of importing only
certain methods from a module.
Something like:
using std::cout;
But still i am new to ruby(3 months precisely), so if you wish you can take
my assertions with a grain of salt.
------ art_59065_16652241.1157072612612--