#119 ✓resolved
Walter McGinnis

Topic Type select broken when javascript off for adding or editing a topic

Reported by Walter McGinnis | November 23rd, 2008 @ 02:41 PM | in 1.2

To recreate, turn JS off in your browser. "Add item" link from menu bar, fill out first form, choose Topic for "About a?" and click choose.

You get a trace like this:

NoMethodError in Topics#new

Showing topics/_topic_types.rhtml where line #3 raised:

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.inject Extracted source (around line #3):

1:

2: About a? 3: <%= topic_type_select_with_indent('topic', 'topic_type_id', topic_types, :id, :name, {}, {:class=>"select", :tabindex => '1'}, (!defined?(pre_options).nil? ? pre_options : Array.new)) %> 4:
Trace of template inclusion: /topics/_pick_form.rhtml, /topics/new.rhtml

Interestingly, at least in development mode, using a topic's "edit" link from the tab may work fine, but once the "Add item" problem is triggered, edits will fail with the same error, too.

Cheers, Walter

Comments and changes to this ticket

  • Walter McGinnis

    Walter McGinnis November 23rd, 2008 @ 02:44 PM

    Interestingly, in development mode at least, even if you turn on JS again and successfully use the "Add item' form to add a new topic, edits will fail until you restart mongrel.

    Cheers, Walter

  • Kieran P

    Kieran P November 24th, 2008 @ 10:29 AM

    • State changed from “new” to “resolved”

    From what I can tell, this happened when trying to building the topic type select options from an blank array (Rails assumes it's not empty, the inject error is traced back to the options_for_select call in the topic_type_select_with_indent method).

    I've added extra checks so it only calls options_for_select when the Array is new blank. It seems to do the trick for both adding the item and editing the item. Fix has been pushed to master.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Kete was developed by Horowhenua Library Trust and Katipo Communications Ltd. to build a digital library of Horowhenua material.

People watching this ticket

Pages