Ruby on Rails Sunday, May 1, 2011

On 30 April 2011 22:38, David Mr. <lists@ruby-forum.com> wrote:
> Colin Law wrote in post #995978:
>> On 30 April 2011 18:00, David Mr. <lists@ruby-forum.com> wrote:
>>>>
>>>> So gamma[:C] is not a collection. Have a look at the Rails Guide on
>>>
>>>
>>> attr_accessor :setA, :setB, :setAList, :setBList, :google
>>
>> First I would stick to the Rails conventions when naming things, so
>> these should be set_a and so on.
>>
>>> before_create :setup_data
>>> before_save :setup_data
>>> def setup_data
>>>  debugger
>>>  setax = []
>>>  setbx = []
>>
>> You don't need the above as split will return an array
>>
>>>  setax = setA.split(" ")
>>>  setbx = setB.split(" ")
>>
>> Are you saying that this method gets called ok but at this point,
>> checked in the debugger, that setA has a sensible value but setax does
>> not?
>>
>> It might help also if you explained whether any of the variables are
>> db columns and which are just instance variables.
>>
>> Colin
>
> As a quick reply...
>
> Yes setA has a sensible -as expected value, but setax is always nil.  I
> can go to the debugger window and do setax = setA.split(" ") and then
> setax has the proper value.  How is that happening?

So if you put a break point immediately after
setax = setA.split(" ")
then setax is nil, but if you then (while still broken) do
setax=setA.split(" ") then setax gets a value.
If so I find that most remarkable.

You have not said how setax and setbx are defined. Are they db cols
for the model in which setup_data is defined or what?

Colin

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment