Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- here is my live search code: I am a beginner and am trying to get this live search code working in RoR 3. I have already installed the prototype legacy helper. I have 3 pages that relate to the problem. I am including them below, they are entries_controller, _search.html.erb, and index.html.erb. I am also including the routes.rb. I am also including the full trace at the end. Here is the error msg I am recieving:
- ActionController::RoutingError in Entries#index
- Showing /home/rhino/esecretary/app/views/entries/index.html.erb where line #12 raised:
- No route matches {:controller=>"entries", :escape=>false, :action=>"search"}
- index.html.erb:
- <%= text_field_tag(:search) %><br>
- <div id=search_indicator_div
- style="postition: absolute; left: your_X px; top: your_Y px">
- <%= image_tag("indicator.gif", :id => 'indicator_gif_id',
- :style => 'display:none') %>
- </div>
- <%= observe_field(:search,
- :frequency => 0.5,
- :update => 'results',
- :url => { :action => :search },
- :loading => "Element.show('indicator_gif_id')",
- :complete => "Element.hide('indicator_gif_id')") %>
- <span id="results"></span>
- entries_controller:
- class EntriesController < ApplicationController
- def search
- @q = request.raw_post
- # optionally handle the query however you'd like
- # fetch some results from a database
- @results = Entry.find(:all,
- :conditions => [ "pointer LIKE ?", "%" + @q +"%"])
- end
- # GET /entries
- # GET /entries.xml
- def index
- @entries = Entry.all
- respond_to do |format|
- format.html # index.html.erb
- format.xml { render :xml => @entries }
- end
- end
- # GET /entries/1
- # GET /entries/1.xml
- def show
- @entry = Entry.find(params[:id])
- respond_to do |format|
- format.html # show.html.erb
- format.xml { render :xml => @entry }
- end
- end
- # GET /entries/new
- # GET /entries/new.xml
- def new
- @entry = Entry.new
- respond_to do |format|
- format.html # new.html.erb
- format.xml { render :xml => @entry }
- end
- end
- # GET /entries/1/edit
- def edit
- @entry = Entry.find(params[:id])
- end
- # POST /entries
- # POST /entries.xml
- def create
- @entry = Entry.new(params[:entry])
- respond_to do |format|
- if @entry.save
- format.html { redirect_to(@entry, :notice => 'Entry was successfully created.') }
- format.xml { render :xml => @entry, :status => :created, :location => @entry }
- else
- format.html { render :action => "new" }
- format.xml { render :xml => @entry.errors, :status => :unprocessable_entity }
- end
- end
- end
- # PUT /entries/1
- # PUT /entries/1.xml
- def update
- @entry = Entry.find(params[:id])
- respond_to do |format|
- if @entry.update_attributes(params[:entry])
- format.html { redirect_to(@entry, :notice => 'Entry was successfully updated.') }
- format.xml { head :ok }
- else
- format.html { render :action => "edit" }
- format.xml { render :xml => @entry.errors, :status => :unprocessable_entity }
- end
- end
- end
- # DELETE /entries/1
- # DELETE /entries/1.xml
- def destroy
- @entry = Entry.find(params[:id])
- @entry.destroy
- respond_to do |format|
- format.html { redirect_to(entries_url) }
- format.xml { head :ok }
- end
- end
- end
- _search.html.erb
- <% if @results.length > 0 && @q != ''-%>
- <table border=1 cellpadding=3px cellspacing=0px>
- <tr>
- <td align=center>
- <b>Reference</b>
- </td>
- <td align=center>
- <b>Passage</b>
- </td>
- </tr>
- <% for result in @results %>
- <tr>
- <td align=center>
- <%= result.pointer -%>:<%= result.reference -%>
- </td>
- <!--<td>
- <%= result.passage.gsub(/(#{@q})/i, '<b>\1</b>') -%>
- </td>-->
- </tr>
- </table>
- <% end %>
- <% else -%>
- <% if @q != '' -%>
- Sorry, there are no results for:
- <br> <b><%=h @q -%>
- <% end -%>
- <% end -%>
- routes.rb:
- Esecretary::Application.routes.draw do
- resources :entries
- resources :posts
- get "entries/index"
- root :to => "entries#index"
- end
- Full trace:
- actionpack (3.0.1) lib/action_dispatch/routing/route_set.rb:424:in `raise_routing_error'
- actionpack (3.0.1) lib/action_dispatch/routing/route_set.rb:406:in `generate'
- actionpack (3.0.1) lib/action_dispatch/routing/route_set.rb:453:in `generate'
- actionpack (3.0.1) lib/action_dispatch/routing/route_set.rb:481:in `url_for'
- actionpack (3.0.1) lib/action_dispatch/routing/url_for.rb:132:in `url_for'
- actionpack (3.0.1) lib/action_view/helpers/url_helper.rb:99:in `url_for'
- actionpack (3.0.1) lib/action_view/helpers/prototype_helper.rb:134:in `remote_function'
- vendor/plugins/prototype_legacy_helper/lib/prototype_helper.rb:422:in `build_observer'
- vendor/plugins/prototype_legacy_helper/lib/prototype_helper.rb:361:in `observe_field'
- app/views/entries/index.html.erb:12:in `_app_views_entries_index_html_erb__77333713__617317678_0'
- actionpack (3.0.1) lib/action_view/template.rb:135:in `send'
- actionpack (3.0.1) lib/action_view/template.rb:135:in `render'
- activesupport (3.0.1) lib/active_support/notifications.rb:54:in `instrument'
- actionpack (3.0.1) lib/action_view/template.rb:127:in `render'
- actionpack (3.0.1) lib/action_view/render/rendering.rb:59:in `_render_template'
- activesupport (3.0.1) lib/active_support/notifications.rb:52:in `instrument'
- activesupport (3.0.1) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
- activesupport (3.0.1) lib/active_support/notifications.rb:52:in `instrument'
- actionpack (3.0.1) lib/action_view/render/rendering.rb:56:in `_render_template'
- actionpack (3.0.1) lib/action_view/render/rendering.rb:26:in `render'
- actionpack (3.0.1) lib/abstract_controller/rendering.rb:114:in `_render_template'
- actionpack (3.0.1) lib/abstract_controller/rendering.rb:108:in `render_to_body'
- actionpack (3.0.1) lib/action_controller/metal/renderers.rb:47:in `render_to_body'
- actionpack (3.0.1) lib/action_controller/metal/compatibility.rb:55:in `render_to_body'
- actionpack (3.0.1) lib/abstract_controller/rendering.rb:101:in `render_to_string'
- actionpack (3.0.1) lib/abstract_controller/rendering.rb:92:in `render'
- actionpack (3.0.1) lib/action_controller/metal/rendering.rb:17:in `render'
- actionpack (3.0.1) lib/action_controller/metal/instrumentation.rb:40:in `render'
- activesupport (3.0.1) lib/active_support/core_ext/benchmark.rb:5:in `ms'
- /usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
- activesupport (3.0.1) lib/active_support/core_ext/benchmark.rb:5:in `ms'
- actionpack (3.0.1) lib/action_controller/metal/instrumentation.rb:40:in `render'
- actionpack (3.0.1) lib/action_controller/metal/instrumentation.rb:78:in `cleanup_view_runtime'
- activerecord (3.0.1) lib/active_record/railties/controller_runtime.rb:15:in `cleanup_view_runtime'
- actionpack (3.0.1) lib/action_controller/metal/instrumentation.rb:39:in `render'
- actionpack (3.0.1) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
- actionpack (3.0.1) lib/action_controller/metal/mime_responds.rb:261
- actionpack (3.0.1) lib/action_controller/metal/mime_responds.rb:192:in `call'
- actionpack (3.0.1) lib/action_controller/metal/mime_responds.rb:192:in `respond_to'
- app/controllers/entries_controller.rb:21:in `index'
- actionpack (3.0.1) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
- actionpack (3.0.1) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
- actionpack (3.0.1) lib/abstract_controller/base.rb:150:in `process_action'
- actionpack (3.0.1) lib/action_controller/metal/rendering.rb:11:in `process_action'
- actionpack (3.0.1) lib/abstract_controller/callbacks.rb:18:in `process_action'
- activesupport (3.0.1) lib/active_support/callbacks.rb:435:in `_run__780865482__process_action__199225275__callbacks'
- activesupport (3.0.1) lib/active_support/callbacks.rb:409:in `send'
- activesupport (3.0.1) lib/active_support/callbacks.rb:409:in `_run_process_action_callbacks'
- activesupport (3.0.1) lib/active_support/callbacks.rb:93:in `send'
- activesupport (3.0.1) lib/active_support/callbacks.rb:93:in `run_callbacks'
- actionpack (3.0.1) lib/abstract_controller/callbacks.rb:17:in `process_action'
- actionpack (3.0.1) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
- activesupport (3.0.1) lib/active_support/notifications.rb:52:in `instrument'
- activesupport (3.0.1) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
- activesupport (3.0.1) lib/active_support/notifications.rb:52:in `instrument'
- actionpack (3.0.1) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
- actionpack (3.0.1) lib/action_controller/metal/rescue.rb:17:in `process_action'
- actionpack (3.0.1) lib/abstract_controller/base.rb:119:in `process'
- actionpack (3.0.1) lib/abstract_controller/rendering.rb:40:in `process'
- actionpack (3.0.1) lib/action_controller/metal.rb:133:in `dispatch'
- actionpack (3.0.1) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
- actionpack (3.0.1) lib/action_controller/metal.rb:173
- actionpack (3.0.1) lib/action_dispatch/routing/route_set.rb:62:in `call'
- actionpack (3.0.1) lib/action_dispatch/routing/route_set.rb:62:in `dispatch'
- actionpack (3.0.1) lib/action_dispatch/routing/route_set.rb:27:in `call'
- rack-mount (0.6.13) lib/rack/mount/route_set.rb:148:in `call'
- rack-mount (0.6.13) lib/rack/mount/code_generation.rb:93:in `recognize'
- rack-mount (0.6.13) lib/rack/mount/code_generation.rb:68:in `optimized_each'
- rack-mount (0.6.13) lib/rack/mount/code_generation.rb:92:in `recognize'
- rack-mount (0.6.13) lib/rack/mount/route_set.rb:139:in `call'
- actionpack (3.0.1) lib/action_dispatch/routing/route_set.rb:492:in `call'
- actionpack (3.0.1) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
- actionpack (3.0.1) lib/action_dispatch/middleware/head.rb:14:in `call'
- rack (1.2.1) lib/rack/methodoverride.rb:24:in `call'
- actionpack (3.0.1) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
- actionpack (3.0.1) lib/action_dispatch/middleware/flash.rb:182:in `call'
- actionpack (3.0.1) lib/action_dispatch/middleware/session/abstract_store.rb:149:in `call'
- actionpack (3.0.1) lib/action_dispatch/middleware/cookies.rb:287:in `call'
- activerecord (3.0.1) lib/active_record/query_cache.rb:32:in `call'
- activerecord (3.0.1) lib/active_record/connection_adapters/abstract/query_cache.rb:28:in `cache'
- activerecord (3.0.1) lib/active_record/query_cache.rb:12:in `cache'
- activerecord (3.0.1) lib/active_record/query_cache.rb:31:in `call'
- activerecord (3.0.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:355:in `call'
- actionpack (3.0.1) lib/action_dispatch/middleware/callbacks.rb:46:in `call'
- activesupport (3.0.1) lib/active_support/callbacks.rb:415:in `_run_call_callbacks'
- actionpack (3.0.1) lib/action_dispatch/middleware/callbacks.rb:44:in `call'
- rack (1.2.1) lib/rack/sendfile.rb:107:in `call'
- actionpack (3.0.1) lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
- actionpack (3.0.1) lib/action_dispatch/middleware/show_exceptions.rb:46:in `call'
- railties (3.0.1) lib/rails/rack/logger.rb:13:in `call'
- rack (1.2.1) lib/rack/runtime.rb:17:in `call'
- activesupport (3.0.1) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
- rack (1.2.1) lib/rack/lock.rb:11:in `call'
- rack (1.2.1) lib/rack/lock.rb:11:in `synchronize'
- rack (1.2.1) lib/rack/lock.rb:11:in `call'
- actionpack (3.0.1) lib/action_dispatch/middleware/static.rb:30:in `call'
- railties (3.0.1) lib/rails/application.rb:168:in `call'
- railties (3.0.1) lib/rails/application.rb:77:in `send'
- railties (3.0.1) lib/rails/application.rb:77:in `method_missing'
- railties (3.0.1) lib/rails/rack/log_tailer.rb:14:in `call'
- rack (1.2.1) lib/rack/content_length.rb:13:in `call'
- rack (1.2.1) lib/rack/handler/webrick.rb:52:in `service'
- /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
- /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
- /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
- /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
- /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
- /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
- /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
- /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
- /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
- /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
- rack (1.2.1) lib/rack/handler/webrick.rb:13:in `run'
- rack (1.2.1) lib/rack/server.rb:213:in `start'
- railties (3.0.1) lib/rails/commands/server.rb:65:in `start'
- railties (3.0.1) lib/rails/commands.rb:30
- railties (3.0.1) lib/rails/commands.rb:27:in `tap'
- railties (3.0.1) lib/rails/commands.rb:27
- script/rails:6:in `require'
- script/rails:6
Add Comment
Please, Sign In to add comment