3 Replies Latest reply on Oct 21, 2013 3:30 AM by Kutir Mobility

    Find on  PropertyBag model

    Ruben Ruben

      I'm trying to implement a search function for my Perslid model:

       

      Controller:

       

        def search

          render :action => :search, :back => url_for(:action => :index)

        end

       

        def do_search

          @perslid = Perslid.find(:all, :conditions => {'id' => @params['id']})

           if @perslid

            render :action => :do_search, :back => url_for(:action => :index)

           else

            redirect :action => :index

          end

        end

       

      search view:

       

        <div data-role="content">

          <ul data-role="listview">

            <form method="POST" action="<%= url_for :action => :do_search%>" >

              Pers. Nr.: <input type="search" id="id" name="id">

              <input type="submit" value="Search">

            </form>

          </ul>

        </div>

       

      the do search view is just a copy of the default show.erb.

       

      I'm getting no results from the find. However if I try: find(:all).first, it shows the first value. What am I doing wrong?

       

      Thanks!