view <%= select( :order, :hcins, { "Man" => 3, "Is" => 5}) %> (hcins is string value) controller (order) def create @order =Order.new(params[:order]) @order.user = User.find(session[:user_id]) @order.ucret= @order.hcins.to_d * @order.hboy if @order.save redirect_to :controller=>"user",:action =>''index'' flash[:notice] = "Completed" else flash[:notice] = "Problem end end when I submit the form "hcins" gets "3 or 5" but I like to get text of selection("man" or "is") for "hcins" and values for "ucret" calculation. how should I do it? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Lamer Lamer wrote:> view > <%= select( :order, :hcins, { "Man" => 3, "Is" => 5}) %> > (hcins is string value) > > controller (order) > > def create > > @order =Order.new(params[:order]) > > @order.user = User.find(session[:user_id]) > > @order.ucret= @order.hcins.to_d * @order.hboy > > if @order.save > redirect_to :controller=>"user",:action =>''index'' > flash[:notice] = "Completed" > else > flash[:notice] = "Problem > end > > end > > when I submit the form "hcins" gets "3 or 5" but I like to get text of > selection("man" or "is") for "hcins" and values for "ucret" calculation. > > how should I do it?Did you try ... <%= select( :order, :hcins, [["Man", 3], ["Is", 5]]) %> ~Jeremy -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> Did you try ... > > <%= select( :order, :hcins, [["Man", 3], ["Is", 5]]) %> > > > > ~Jeremyyeah I tried and faced with same result. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Jun 8, 6:18 pm, Lamer Lamer <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> view > <%= select( :order, :hcins, { "Man" => 3, "Is" => 5}) %> > (hcins is string value) >[...]> when I submit the form "hcins" gets "3 or 5" but I like to get text of > selection("man" or "is") for "hcins" and values for "ucret" calculation. >If you need both the text and the numerical value then you need to store in your app the mapping of values to labels. Fred -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.