Forum: Ruby on Rails One question on select tag

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
145e373624d173d2226a3dec4c563dfe?d=identicon&s=25 jack.tang (Guest)
on 2007-02-08 19:19
(Received via mailing list)
Hi

I am now trying to learn some rails tag and encounter one question on
"select" tag.

== Controller

def post_book
    @book = Book.new(:type => "CS")
end

== Viewer

<%=select "book", "type", [
                                  [" tale", "T"],
                                  ["computer science" ,"CS"]...
                                  ],
                                  {....}
                                  %>
When I open the page xxx/yyy/post_book, it throws exception: wrong
argument type String (expected Module). And the exception occured line
number is the "select" tag. So could you please tell me how to solve
the problem?

-- jack
Aa33613fb12765fe505efea87844a12e?d=identicon&s=25 Craig White (Guest)
on 2007-02-08 19:29
(Received via mailing list)
On Thu, 2007-02-08 at 10:18 -0800, jack.tang wrote:
>
> number is the "select" tag. So could you please tell me how to solve
> the problem?
----
I don't recall ever setting values that way but I don't always do
shortest code...

def post_book
  @book = Book.new
  @book.type = "CS"
end

but I wonder if 'type' is a bad name for a field (reserved word?) and
would probably use btype or book_type just in case

Craig
145e373624d173d2226a3dec4c563dfe?d=identicon&s=25 jack.tang (Guest)
on 2007-02-08 19:36
(Received via mailing list)
On Feb 9, 2:29 am, Craig White <c...@tobyhouse.com> wrote:
> > end
> > argument type String (expected Module). And the exception occured line
> end
>
> but I wonder if 'type' is a bad name for a field (reserved word?) and
> would probably use btype or book_type just in case

Craig, thanks for your reminder! it works now :)
This topic is locked and can not be replied to.