SitePoint Sponsor

User Tag List

Results 1 to 10 of 10

Hybrid View

  1. #1
    SitePoint Zealot sethtrain's Avatar
    Join Date
    Dec 2003
    Location
    Paducah, KY
    Posts
    174
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Rails select error

    This code:

    Code:
    <p>
    
       <label for="resource_type">Type</label><br/>
    
       <%= select(:resource, :type, %w{ Web Data }) %>
    
    </p>


    Produces this error:


    Code:
    TypeError in Resources#new
    
    Showing app/views/resources/_form.rhtml where line #6 raised:
    
    wrong argument type String (expected Module)
    
    Extracted source (around line #6):
    
    3:     <legend>Resource General</legend>
    4:
    5:     <p><label for="resource_type">Type</label><br/>
    6:         <%= select(:resource, :type, %w{ Web Data }) %>
    7:      </p>
    8:
    9:     <p><label for="resource_focus_id">Focus</label><br/>
    I took it straight out of the Agile Web Development book (except the
    :include_blank)
    --
    sethtrain

  2. #2
    SitePoint Guru silver trophy Luke Redpath's Avatar
    Join Date
    Mar 2003
    Location
    London
    Posts
    794
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    According to the example in the API docs, the first two parameters should be strings, not symbols - doesn't quite explain the error but give it a go.

  3. #3
    SitePoint Zealot sethtrain's Avatar
    Join Date
    Dec 2003
    Location
    Paducah, KY
    Posts
    174
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, I tried that...

    Still doesn't work.
    --
    sethtrain

  4. #4
    SitePoint Zealot sethtrain's Avatar
    Join Date
    Dec 2003
    Location
    Paducah, KY
    Posts
    174
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What is funny is that doesn't work. But this does:

    Code:
    <%= select("resource", "level", [['Primary', 'EP'], ['4th Grade', '4'], ['5th Grade', '5'], ['6th Grade', '6'], ['7th Grade', '7'], ['8th Grade', '8'], ['High School', 'HS'] ], {:include_blank => true})%>
    If I try this:

    Code:
    <%= select("resource", "type", [['Web', 'Web'], ['Data', 'Data'] ], {:include_blank => true})%>
    It doesn't work either
    --
    sethtrain

  5. #5
    SitePoint Guru silver trophy Luke Redpath's Avatar
    Join Date
    Mar 2003
    Location
    London
    Posts
    794
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You might want to consider taking this one to the mailing list.

  6. #6
    SitePoint Enthusiast Stevenwulf's Avatar
    Join Date
    May 2002
    Location
    Berkeley
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you tried:

    <%= select("resource", "type", ["Web", "Data"]) %>

  7. #7
    SitePoint Zealot sethtrain's Avatar
    Join Date
    Dec 2003
    Location
    Paducah, KY
    Posts
    174
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Stevenwulf
    Have you tried:

    <%= select("resource", "type", ["Web", "Data"]) %>
    Nope.


    Took this to the mailing list yesterday but no remarks. It might have gotten lost.
    --
    sethtrain

  8. #8
    SitePoint Enthusiast Stevenwulf's Avatar
    Join Date
    May 2002
    Location
    Berkeley
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Perhaps you should give it a shot.

    I'm using something similar and it works fine

    <%= select("object_name", "object_attribute", ["val1", "val2", "val3"]) %>

  9. #9
    SitePoint Zealot sethtrain's Avatar
    Join Date
    Dec 2003
    Location
    Paducah, KY
    Posts
    174
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That didn't work either, still getting
    Code:
    wrong argument type String (expected Module)
    I don't know if it has something to do with the place it is located because I am using other selects down the page and they work fine.
    --
    sethtrain

  10. #10
    SitePoint Zealot sethtrain's Avatar
    Join Date
    Dec 2003
    Location
    Paducah, KY
    Posts
    174
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    FOUND IT!!!!!!!

    "type" is a Rails method. It isn't in the reserved words list or anything like that but it just doesn't work. Changed it and it worked.
    --
    sethtrain


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
  •