So I came across a bug as I was testing my newly written code to check whether handles and usernames have already been registered in the database. This worked fine when I want to sign up. However, when I want to update a user's profile, it would not let me update my profile with my existing email because the email already exists in the database. Pretty obvious that there's a bug there.
So when I did my AJAX checking, I had to determine what type of action I was doing (i.e. signing up, updating...). I had a parameter called action which would be sent in the query string, telling the controller what kind of action I am doing. The problem is, whenever I did that, my code for some reason could not recognise what kind of action I'm performing. When I printed out params[:action], it gave me the controller's method name.
Out of frustration, I hopped onto irc to get some real-time help. Turns out that action was a reserved name used for routing purposes, which determines which method of the controller you're calling to. D'oh! Obviously I should've known this as my code is scattered with :action => "something".
So I changed the parameter name to actiontype and it worked perfectly!
Thursday, 23 August 2007
Bug #1: AJAX checking in certain actions
Subscribe to:
Post Comments (Atom)
2 comments:
Oh my ... I have no idea what you're going on about.
At least, you've learnt heaps from your degree.
I'm not sure what i learnt =p
Good luck with your thesis !!! Gambattee
hehe, thanks ying ning. didn't know you found your way to my thesis blog.
hope everything is good on your end :)
Post a Comment