Search code examples
ruby-on-railsslim-lang

ruby on rails slim how to handle a value in select


I want to save the value of the option after submit .this a part of code (slim) but i can use also rubyon rails. please someone have any idea the select item is reference- brand- color- model- gender-ext_product_id

well.search-form
form
input type="hidden" value="put" name="_method"
- if search.scope == :my_items
  input type="hidden" value="#{search_params.published}" name="published"
  input type="hidden" value="#{search_params.query}" name="query"
fieldset
  .row-fluid 
    .span8
      label for="query" =translate"keyword"
      select#query.selectoption name="keywordSearch" 
         option[value="reference" name="reference" selected=("selected" if @_source=="reference")] Reference
         option[value="brand" name="brand" selected=("selected" if @_source=="brand")] Brand
         option[value="model" name="model" selected=("selected" if @_source=="model")] Model
         option[value="color" name="color"  selected=("selected" if @_source=="color")] Color
         option[value="ext_product_id" name="ext_product_id" selected=("selected" if @_source=="ext_product_id")] Productid
         option[value="gender" name="gender" selected=("selected" if @_source=="gender")] Gender

Solution

  • i found a solution it just to use the name of the select in option selected like this

    select#query.selectoption  name="keywordSearch"
             option[value="reference" name="reference" selected=("selected" if @keywordSearch =="reference")] Reference 
             option[value="brand" name="brand" selected=("selected" if @keywordSearch=="brand")] Brand 
             option[value="model" name="model" selected=("selected" if @keywordSearch=="model")] Model
             option[value="color" name="color"  selected=("selected" if @keywordSearch=="color")] Color
             option[value="ext_product_id" name="ext_product_id" selected=("selected" if @keywordSearch=="ext_product_id")] Productid
             option[value="gender" name="gender" selected=("selected" if @keywordSearch=="gender")] Gender