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?
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?
> <%=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?
----
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