Jeff, you are right; it is important to see how the pieces come together, else "knowledge" is just an illusion.
This danger (of "*knowing without understanding*") existed also with traditional languages/tools, but it is so higher with Ruby and Rails, where all seems so "magic"... and "fluid"... that sometimes leaves you "empty". So, I am so glad that you and Gabriel followed that tutorial the hard way. Thanks so much for the kind words Raul On Thu, Jan 1, 2009 at 3:01 PM, Jefferson Bicca Charczuk < [email protected]> wrote: > Hi Gabriel and Raul, > > Another way to fix the issue is to call the countries method > explicitly into the new and edit methods from StudentsController. > So this should instantiate and populate the countries hash properly. > > By the way: I didn't knew the before_filter! Thanks for letting us > know, as I try not to download the homework/exercices sources as this > force me to read everything from the beginning until the end of the > exercices! > > Thanks Raul for the tips and congratulations for having the time and > being here so active through this course, answering the doubts and > discussing! I know this is my first post here, but I have been > following the course since the beginning! > > Cheers, > Jeff. > > On Tue, Dec 9, 2008 at 3:35 PM, raul parolari <[email protected]> > wrote: > > Gabriel > > > >> ..motivate us to get the answers by ourselves, that's quite something! > > > > excellent: that's the spirit! > > > > By the way, I think that that filter was called for some actions that do > not > > need it (but I let you find the ones), so the line should be shorter, > > although I did not test. > > Of course, that does not cause a problem; but if it something is not > needed, > > it is "noise" (which is a problem :-). > > > >> I'm not used to work with the Rails debugger, > > > > I did not mean the debugger (although it is easy). Just the debug > method > > in a view, like: > > > > countries = <%= debug countries %> > > > > which dumps the structure in a nice yaml format. > > > > (Or in a controller just a 'puts' statement, or use the logger). > > > > This allows you to zero into a problem quickly, or at least to exclude > some > > branches from your analysis. > > > > Let me know if you find more bugs (but first try to fix them for me :-) > > > > Raul > > > > > > > > > > On Tue, Dec 9, 2008 at 9:00 AM, Gabriel <[email protected]> wrote: > >> > >> Thanks Raul, your response to my worries is, as always, fast and > >> precise. You are able to elucidate the problem and motivate us to get > the > >> answers by ourselves, that's quite something! > >> I'm not used to work with the Rails debugger, but already looking for > some > >> resources to be able to understand it as soon as possible. > >> Buon Natale! Cheers! > >> > >> 2008/12/9 raul parolari <[email protected]> > >>> > >>> Gabriel, > >>> > >>> this type of problems is the most common occurrence when building > an > >>> application; "a variable is nil somewhere..". It is quite important > that you > >>> do something more than reading the trace. > >>> > >>> The trace tells you that this happens when calling > >>> "select_country_choices"...; this method is one liner in a helper > module, > >>> and it is accessing one variable (@countries). > >>> > >>> So, the question you should be asking is: is @countries nil? let's put > a > >>> debug statement somewhere before the call that produces the exception. > >>> > >>> And if you find that it is nil, the next step is: who should set it? > the > >>> call is from the students_helper, so it is likely that the code is in > the > >>> Students Controller... ah, the method to provide @countries is there, > but is > >>> someone calling it? (If not this is the problem; the guy who wrote the > >>> tutorial forgot to mention that this method should be called.. let's > see: > >>> where should I put the call? in all the actions that need it? uhm, I > >>> remember this thing about "filters"...). > >>> > >>> This is the process that you should follow next time (I know that you > are > >>> able to); not stop at the exception and say "it does not work". Anyone > one > >>> can do a "homework", following mechanically the example; but this is > not > >>> mechanical, and so it is a lot more useful. > >>> ------- > >>> > >>> Having said that, in the tutorial I forgot to mention that you need a > >>> before_filter in the students_controller: > >>> > >>> before_filter :countries, :only => [ :new, :edit, :update, :create ] > >>> > >>> By the way, the line is in the zip of the project (the link is in > section > >>> "2. An international Online College"). > >>> > >>> In any case, kudos for following line by line the construction of the > >>> project (you are probably one of the few, if not the only one, who > tried > >>> that). But I invite you to do something more next time; if there is an > >>> error, dive into it, and see if you can fix it... or at least go near > to the > >>> exact reason. The feeling will be special, > >>> > >>> Raul > >>> > >>> > >>> On Tue, Dec 9, 2008 at 7:24 AM, Gabriel <[email protected]> wrote: > >>>> > >>>> Hi folks. > >>>> I'm following the Action View Helpers tutorial but something's going > >>>> wrong. > >>>> Everything goes well until step 2.5, where we populate the database > with > >>>> some sample data. > >>>> When I run the application, I can view the "index" and "show" views, > but > >>>> the "edit" and "new" views (where the 'editable_student_form' partial > is > >>>> rendered), I'm getting a "NoMethodError" when calling > >>>> "select_country_choices" (at least is where the trace stops). > >>>> The error message is: > >>>> You have a nil object when you didn't expect it! > >>>> You might have expected an instance of Array. > >>>> The error occurred while evaluating nil.map" > >>>> I'm not getting the "select_country_choices" when I call > >>>> "Student.methods" or "StudentsHelper.methods" in Rails Console as > well. > >>>> How can I get things right? > >>>> Thanks, > >>>> Gabriel. > >>>> > >>> > >> > >> > >> > > > > > > > > > > > > > > -- > Jefferson Bicca Charczuk > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "ruby-on-rails-programming-with-passion" group. To unsubscribe from this group, send email to ruby-on-rails-programming-with-passion-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/ruby-on-rails-programming-with-passion?hl=en?hl=en -~----------~----~----~----~------~----~------~--~---
