SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot ricklach's Avatar
    Join Date
    Nov 2004
    Location
    Victoria BC
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    NoMethodError in Admin/tag#new

    I have the following code in the tag.rb model:
    Code:
        1. TAG_GROUP = [
       2.     #Displayed        stored in db
       3.     ["Name",        "name"],
       4.     ["Relationship",  "relationship"],
       5.     ["Birth",    "birth"],
       6.     ["Death",    "death"],
       7.     ["Burial",        "burial"],
       8.     ["Marriage",      "marriage"],
       9.     ["Divorce",   "divorce"],
      10.     ["History",   "history"],
      11.     ["Address",   "address"],
      12.     ["Other Event",  "other_event"]
      13.   ]
    A list of name/value pairs for a select box. I have the following code in the partial _form.rhtml file:
    Code:
     <p><label for="tag_tag_group">Tag Group</label><br/>
       <%= form.select :tag_group, Tag::TAG_GROUP, :prompt=>"Select a tag group"  %></p>
    This code throws the following error: 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.select. Can anyone tell me why the error? The code worked before I changed to a select box and the array exists.
    Ruby, Ruby when will you be mine

  2. #2
    SitePoint Member
    Join Date
    Nov 2006
    Location
    Austin, TX
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    can you post all your view code?
    form.select does not make much sense. What did you have there before?
    wtf242
    ProgrammingBooks.org - Programming Books Ranked by Programmers
    Turn of the Crank - My blog
    Robot Walrus - My Art Prints/Posters Blog

  3. #3
    SitePoint Zealot ricklach's Avatar
    Join Date
    Nov 2004
    Location
    Victoria BC
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is the _form.rhtml code:
    Code:
    <%= error_messages_for 'tag' %>
    
    <!--[form:tag]-->
    <p><label for="tag_tag_name">Tag name</label><br/>
    <%= text_field 'tag', 'tag_name'  %></p>
    
    <p><label for="tag_gedcom_name">Gedcom name</label><br/>
    <%= text_field 'tag', 'gedcom_name'  %></p>
    
    <p><label for="tag_lds_only">Lds only</label><br/>
    <select id="tag_lds_only" name="tag[lds_only]"><option value="false">False</option><option value="true">True</option></select></p>
    
    <p><label for="tag_tag_group">Tag Group</label><br/>
    <%= form.select :tag_group, Tag::TAG_GROUP, :prompt=>"Select a tag group"  %></p>
    
    <p><label for="tag_sentence">Sentence</label><br/>
    <%= text_field 'tag', 'sentence'  %></p>
    <!--[eoform:tag]-->
    and here is the new.rhtml code:
    Code:
     <h1>New tag</h1>
    
    <% form_tag :action => 'create' do %>
      <%= render :partial => 'form' %>
      <%= submit_tag "Create" %>
    <% end %>
    
    <%= link_to 'Back', :action => 'list' %>
    Does this help?
    Ruby, Ruby when will you be mine

  4. #4
    SitePoint Guru
    Join Date
    Aug 2005
    Posts
    986
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There is no `form` object so `form.select` results in an error.

    http://railsmanual.org/module/Action...sHelper/select

  5. #5
    SitePoint Zealot ricklach's Avatar
    Join Date
    Nov 2004
    Location
    Victoria BC
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, that helped and fixed the problem.
    Ruby, Ruby when will you be mine


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •