i have problem to make combobox in rails can you help me.
i try this syntax
<%= f.select(:Status) %>
Status is my field in database that have 2 value “perempuan” and
“laki-laki”. but i always got error in my rails
and the second problem i want to get value from 2 diffrent field, first
from text_field, and second from select_date, and i want to save it in
one field “TTL” in database, this is the syntax,
<%= f.label :ttl %>
<%= f.label :":" %>
<%= f.text_field :TTL %>
<%= select_date %>
i confuse, how to get select_date value and concat it with value form
text_field, and then save it in field “TTL” in database.
<%=select_tag :Status, options_for_select(%w{ Perempuan Laki-Laki
})%>
but, i didn’t work, i just need to get value from that combobox, and
send it to query insert to field “Status” in database, but when i try
rails look it like null value
and for second problem, i get this syntax.
<%= f.label :ttl %>
<%= f.label :":" %>
<%= f.text_field :TTL %>
<%= select_date %>
i want to concate value from “<%= f.text_field :TTL %>” and value from
“<%= select_date %>” and send it to update field TTL in database
<%=select_tag :Status, options_for_select(%w{ Perempuan Laki-Laki
})%>
but, i didn’t work, i just need to get value from that combobox, and
send it to query insert to field “Status” in database, but when i try
rails look it like null value
First you need to determine which area is going wrong.
Firstly is the html that is being generated what you expect. Have a
look at the html of the page (using View > Page Source or similar in
your browser). Does that look ok?
Secondly perhaps the data is not being sent to the server correctly.
Look in log/development.log to check that the data is being passed and
the correct action is being called.
Thirdly perhaps there is an error in the action in the controller.
Have a look at the Rails Guide on Debugging and it will show you
techniques you can use to debug your code.
<%= select_date %>
i want to concate value from “<%= f.text_field :TTL %>” and value from
“<%= select_date %>” and send it to update field TTL in database
It is really better to only have one question at a time, otherwise the
answers will get confusing.
“<%=select_tag :Status, options_for_select(%w{ Perempuan Laki-Laki})%>”
because my field(field status) in database, i config as Set that have
two value “Perempuan” ,and “Laki-Laki”. but when i just write that
syntax rails look value from “<%=select_tag :Status,
options_for_select(%w{ Perempuan Laki-Laki})%>” as null value.
Did you type that last line, or copy and paste from your code?
:Status
or
:status
???
Ruby variables are usually snake-case. Classes are camel-case. Which is
this?
“<%=select_tag :Status, options_for_select(%w{ Perempuan Laki-Laki})%>”
because my field(field status) in database, i config as Set that have
two value “Perempuan” ,and “Laki-Laki”. but when i just write that
syntax rails look value from “<%=select_tag :Status,
options_for_select(%w{ Perempuan Laki-Laki})%>” as null value.
for second problem i change my model file to be like this:
this one
:Status
i copy it from my code (_form.html.rb file)
i want to make like this
<%= f.label :status %>
<%= f.label :":" %>
<%= f.text_field :Status %>
but i didn’t want make input from text_field, i want to input from
select so i change
<%= f.text_field :Status %>
to
<%=select_tag :Status, options_for_select(%w{ Perempuan Laki-Laki
})%>
when i use text_field as input i got the value. but when i change it to
select, rails say it nill value