Re: ajax and partials

On Aug 31, 10:37 am, Dave C. [email protected] wrote:

I am still very new to programming and wonder if I could get some help.

Okay, but this isn’t the help you’re looking for. :wink:

 answer_list = [
   [incorrect_ans_1, incorrect_anno_1],

   [incorrect_ans_6, incorrect_anno_6]

   formatted = {
     :anno_1 => answer_list[0][1],

     :anno_5 => answer_list[4][1],
     :question => self.question,
     :answer_a => answer_list[0][0],

     :answer_e => answer_list[4][0]

From a general software engineering/development standpoint, I’d
suggest you don’t use things like “answer_a” to “answer_e” and so on.
Keep them in arrays, with some constant defining the size. Then you
can just iterate over the array or range. If you need to change the
size of the array, you can then be guaranteed that you haven’t
forgotten to add or remove an entry somewhere.

<%= link_to_remote(
:url =>"/questions/#{@}/_anno_2",

And now a possible forehead-slap moment. Might the space after the @
sign (which you have on some but not quite all of the other lines) be
causing at least part of your problem?

Iterating will also reduce the number of places where you have the
opportunity to make such mistakes. A wise man once said, the best
code is no code at all. See:

(and that’s just from googling that literal phrasing.)


Specialization is for insects. -RAH | Have Pun, Will Babble! -me
Programming Blog: | Work:
Leadership Blog: | Play:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs