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

--~--~---------~--~----~------------~-------~--~----~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/ruby-on-rails-programming-with-passion?hl=en?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to