Forum: Ruby on Rails Problem with 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.
Thiti P. (Guest)
on 2009-02-27 11:18
(Received via mailing list)
i create drop-down memu for organelle by using select_tag but problem
is
 can't get value for form select_tag to database seqfeature but
form.text_field ,it's work  , i don't understand
 why? pls help me
##############################################################
 code for veiw.rhtm:
 <% form_for :seqfeature do |form| %>
  <div class="form_row">
        <label for="seq_name">Sequence Name :</label>
        <%= form.text_field :seq_name %>
  </div>

  <div class="form_row">
        <label for="organelle">Organelle </label>
        <%= select_tag "organelle" , options_for_select(["",
"mitochondrion", "nucleomorph", "plastid", "mitochondrion:
kinetoplast",
"plastid: chloroplast", "plastid: apicoplast", "plastid:
chromoplast",
"plastid: cyanelle", "plastid: leucoplast", "plastid:
protoplastid" ])
%>
  </div>
<%= submit_tag "Submit !", :class => "submit" %>
<% end %>

########################################################################
code for submit controller:

class SubmitController < ApplicationController
  def view
    if request.post? and params[:seqfeature]
      @seqfeature = Seqfeature.new(params[:seqfeature])
      if @seqfeature.save
        render :text => "sequence submitted"
      end
    end
  end
end
 ##### the vale from form insert to  table seqfeatures but i can't
get
value
vimal (Guest)
on 2009-02-27 12:16
(Received via mailing list)
i guess the select tag should be represented as form.select_tag
Thiti P. (Guest)
on 2009-02-27 12:27
vimal wrote:
> i guess the select tag should be represented as form.select_tag

thank a lot but i used it , i have error this this


undefined method `select_tag' for
#<ActionView::Helpers::FormBuilder:0xb788a2a4>
vimal (Guest)
on 2009-02-27 12:48
(Received via mailing list)
use it as a symbol :organelle rather than as a string "organelle"
make sure the :organelle field is made available in ur model seqfeature
Sijo k. (Guest)
on 2009-02-27 14:35
change like

<%= form.select :organelle, (["",
"mitochondrion", "nucleomorph", "plastid", "mitochondrion:
kinetoplast",
"plastid: chloroplast", "plastid: apicoplast", "plastid:
chromoplast",
"plastid: cyanelle", "plastid: leucoplast", "plastid:
protoplastid" ])
%>

     and it will submit to the create action of seqfeature controller.
.There you can write the code as in def view

Sijo
vimal (Guest)
on 2009-02-27 15:07
(Received via mailing list)
I am a little busy
for better understanding
http://guides.rails.info/form_helpers.html
Thiti P. (Guest)
on 2009-02-27 17:57
(Received via mailing list)
thank you very much ,i can fix it  -__-

2009/2/27 Sijo Kg <removed_email_address@domain.invalid>
This topic is locked and can not be replied to.