ruby on rails 3.2 - Not Posting to Sphinx, Using Form, unable to pass instance to form -


i current working on recycling application using gem google-maps-for-rails display map trash bins/recycling bins locations etc. have trash.rb model name , address attributes. gem allows take attributes namely address , convert markers , lat/longitude on map.

i trying implement sphinx feature, lets user wants recycle 'papers' - under category column in table. indexed category column. hope when user post 'paper', address same category have marker displayed on map.

everything got indexed correctly. not getting errors nothing happening.

i having trouble passing current instance form ? editing after thinking last night.

here trashes_controller.rb, focused on index method

class trashescontroller < applicationcontroller   # /trashes   # /trashes.json     def index     @trashes = trash.search(params[:search])     end   end     # /trashes/1   # /trashes/1.json   def show     @trash = trash.find(params[:id])      respond_to |format|       format.html # show.html.erb       format.json { render json: @trash }     end   end    # /trashes/new   # /trashes/new.json   def new     @trash = trash.new      respond_to |format|       format.html # new.html.erb       format.json { render json: @trash }     end   end    # /trashes/1/edit   def edit     @trash = trash.find(params[:id])   end    # post /trashes   # post /trashes.json   def create     @trash = trash.new(params[:trash])      respond_to |format|       if @trash.save         format.html { redirect_to @trash, notice: 'trash created.' }         format.json { render json: @trash, status: :created, location: @trash }       else         format.html { render action: "new" }         format.json { render json: @trash.errors, status: :unprocessable_entity }       end     end   end    # put /trashes/1   # put /trashes/1.json   def update     @trash = trash.find(params[:id])      respond_to |format|       if @trash.update_attributes(params[:trash])         format.html { redirect_to @trash, notice: 'trash updated.' }         format.json { head :no_content }       else         format.html { render action: "edit" }         format.json { render json: @trash.errors, status: :unprocessable_entity }       end     end   end    # delete /trashes/1   # delete /trashes/1.json   def destroy     @trash = trash.find(params[:id])     @trash.destroy      respond_to |format|       format.html { redirect_to trashes_url }       format.json { head :no_content }     end   end 

trash.rb model

class trash < activerecord::base   attr_accessible :address, :name, :category,    acts_as_gmappable    def gmaps4rails_address      "#{address}"   end     def gmaps4rails_infowindow     "#{self.address}"   end  end 

index.html.erb

<h1>listing boston/cambridge trash bin locations</h1> <%= gmaps4rails(@json) %> <table>   <tr>     <th>name</th>     <th>address</th>     <th>category</th>     <th></th>     <th></th>   </tr>  <% @trashes.each |trash| %>   <tr>     <td><%= trash.name %></td>     <td><%= trash.address %></td>     <td><%= trash.category %></td>     <td><%= link_to 'edit', edit_trash_path(trash) %></td>     <td><%= link_to 'destroy', trash, method: :delete, data: { confirm: 'are sure?' } %></td>   </tr> <% end %> </table>  <br />  <%= link_to 'new boston solar powered trash can location', new_trash_path %>  <%= form_tag trashes_path, method: :get %>   <div class="field">     <%= text_field_tag :search, params[:search] %>     <%= submit_tag "search", name: nil %>   </div> <% end %> 

i have changed index.html.erb testing sphinx feature.

<%= link_to 'new boston solar powered trash can location', new_trash_path %>  <%= form_tag trashes_path, method: :get %>   <div class="field">     <%= text_field_tag :search, params[:search] %>     <%= submit_tag "search", name: nil %>   </div> <% end %> 

it searching, used rails console, , can search against model. isn't displaying anything.

you're using @trashes instance variable in view, search results in @searchtrashes instance variable. need use instead of want displayed objects reflect search term.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -