Guest User

Untitled

a guest
Jun 19th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.33 KB | None | 0 0
  1. 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:
  2.  
  3. ActionController::RoutingError in Entries#index
  4. Showing /home/rhino/esecretary/app/views/entries/index.html.erb where line #12 raised:
  5. No route matches {:controller=>"entries", :escape=>false, :action=>"search"}
  6.  
  7.  
  8.  
  9. index.html.erb:
  10.  
  11.  
  12. <%= text_field_tag(:search) %><br>
  13.  
  14.  
  15. <div id=search_indicator_div
  16. style="postition: absolute; left: your_X px; top: your_Y px">
  17. <%= image_tag("indicator.gif", :id => 'indicator_gif_id',
  18. :style => 'display:none') %>
  19. </div>
  20.  
  21.  
  22. <%= observe_field(:search,
  23. :frequency => 0.5,
  24. :update => 'results',
  25. :url => { :action => :search },
  26. :loading => "Element.show('indicator_gif_id')",
  27. :complete => "Element.hide('indicator_gif_id')") %>
  28.  
  29.  
  30. <span id="results"></span>
  31.  
  32.  
  33.  
  34. entries_controller:
  35.  
  36. class EntriesController < ApplicationController
  37.  
  38.  
  39. def search
  40. @q = request.raw_post
  41.  
  42. # optionally handle the query however you'd like
  43.  
  44. # fetch some results from a database
  45. @results = Entry.find(:all,
  46. :conditions => [ "pointer LIKE ?", "%" + @q +"%"])
  47. end
  48.  
  49.  
  50.  
  51. # GET /entries
  52. # GET /entries.xml
  53. def index
  54. @entries = Entry.all
  55.  
  56. respond_to do |format|
  57. format.html # index.html.erb
  58. format.xml { render :xml => @entries }
  59. end
  60. end
  61.  
  62. # GET /entries/1
  63. # GET /entries/1.xml
  64. def show
  65. @entry = Entry.find(params[:id])
  66.  
  67. respond_to do |format|
  68. format.html # show.html.erb
  69. format.xml { render :xml => @entry }
  70. end
  71. end
  72.  
  73. # GET /entries/new
  74. # GET /entries/new.xml
  75. def new
  76. @entry = Entry.new
  77.  
  78. respond_to do |format|
  79. format.html # new.html.erb
  80. format.xml { render :xml => @entry }
  81. end
  82. end
  83.  
  84. # GET /entries/1/edit
  85. def edit
  86. @entry = Entry.find(params[:id])
  87. end
  88.  
  89. # POST /entries
  90. # POST /entries.xml
  91. def create
  92. @entry = Entry.new(params[:entry])
  93.  
  94. respond_to do |format|
  95. if @entry.save
  96. format.html { redirect_to(@entry, :notice => 'Entry was successfully created.') }
  97. format.xml { render :xml => @entry, :status => :created, :location => @entry }
  98. else
  99. format.html { render :action => "new" }
  100. format.xml { render :xml => @entry.errors, :status => :unprocessable_entity }
  101. end
  102. end
  103. end
  104.  
  105. # PUT /entries/1
  106. # PUT /entries/1.xml
  107. def update
  108. @entry = Entry.find(params[:id])
  109.  
  110. respond_to do |format|
  111. if @entry.update_attributes(params[:entry])
  112. format.html { redirect_to(@entry, :notice => 'Entry was successfully updated.') }
  113. format.xml { head :ok }
  114. else
  115. format.html { render :action => "edit" }
  116. format.xml { render :xml => @entry.errors, :status => :unprocessable_entity }
  117. end
  118. end
  119. end
  120.  
  121. # DELETE /entries/1
  122. # DELETE /entries/1.xml
  123. def destroy
  124. @entry = Entry.find(params[:id])
  125. @entry.destroy
  126.  
  127. respond_to do |format|
  128. format.html { redirect_to(entries_url) }
  129. format.xml { head :ok }
  130. end
  131. end
  132. end
  133.  
  134.  
  135.  
  136. _search.html.erb
  137.  
  138. <% if @results.length > 0 && @q != ''-%>
  139. <table border=1 cellpadding=3px cellspacing=0px>
  140. <tr>
  141. <td align=center>
  142. <b>Reference</b>
  143. </td>
  144. <td align=center>
  145. <b>Passage</b>
  146. </td>
  147. </tr>
  148.  
  149. <% for result in @results %>
  150. <tr>
  151. <td align=center>
  152. <%= result.pointer -%>:<%= result.reference -%>
  153. </td>
  154. <!--<td>
  155. <%= result.passage.gsub(/(#{@q})/i, '<b>\1</b>') -%>
  156. </td>-->
  157. </tr>
  158. </table>
  159.  
  160. <% end %>
  161.  
  162. <% else -%>
  163. <% if @q != '' -%>
  164. Sorry, there are no results for:
  165. <br> <b><%=h @q -%>
  166. <% end -%>
  167. <% end -%>
  168.  
  169.  
  170.  
  171. routes.rb:
  172.  
  173. Esecretary::Application.routes.draw do
  174. resources :entries
  175.  
  176. resources :posts
  177.  
  178. get "entries/index"
  179. root :to => "entries#index"
  180. end
  181.  
  182.  
  183.  
  184. Full trace:
  185.  
  186. actionpack (3.0.1) lib/action_dispatch/routing/route_set.rb:424:in `raise_routing_error'
  187. actionpack (3.0.1) lib/action_dispatch/routing/route_set.rb:406:in `generate'
  188. actionpack (3.0.1) lib/action_dispatch/routing/route_set.rb:453:in `generate'
  189. actionpack (3.0.1) lib/action_dispatch/routing/route_set.rb:481:in `url_for'
  190. actionpack (3.0.1) lib/action_dispatch/routing/url_for.rb:132:in `url_for'
  191. actionpack (3.0.1) lib/action_view/helpers/url_helper.rb:99:in `url_for'
  192. actionpack (3.0.1) lib/action_view/helpers/prototype_helper.rb:134:in `remote_function'
  193. vendor/plugins/prototype_legacy_helper/lib/prototype_helper.rb:422:in `build_observer'
  194. vendor/plugins/prototype_legacy_helper/lib/prototype_helper.rb:361:in `observe_field'
  195. app/views/entries/index.html.erb:12:in `_app_views_entries_index_html_erb__77333713__617317678_0'
  196. actionpack (3.0.1) lib/action_view/template.rb:135:in `send'
  197. actionpack (3.0.1) lib/action_view/template.rb:135:in `render'
  198. activesupport (3.0.1) lib/active_support/notifications.rb:54:in `instrument'
  199. actionpack (3.0.1) lib/action_view/template.rb:127:in `render'
  200. actionpack (3.0.1) lib/action_view/render/rendering.rb:59:in `_render_template'
  201. activesupport (3.0.1) lib/active_support/notifications.rb:52:in `instrument'
  202. activesupport (3.0.1) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
  203. activesupport (3.0.1) lib/active_support/notifications.rb:52:in `instrument'
  204. actionpack (3.0.1) lib/action_view/render/rendering.rb:56:in `_render_template'
  205. actionpack (3.0.1) lib/action_view/render/rendering.rb:26:in `render'
  206. actionpack (3.0.1) lib/abstract_controller/rendering.rb:114:in `_render_template'
  207. actionpack (3.0.1) lib/abstract_controller/rendering.rb:108:in `render_to_body'
  208. actionpack (3.0.1) lib/action_controller/metal/renderers.rb:47:in `render_to_body'
  209. actionpack (3.0.1) lib/action_controller/metal/compatibility.rb:55:in `render_to_body'
  210. actionpack (3.0.1) lib/abstract_controller/rendering.rb:101:in `render_to_string'
  211. actionpack (3.0.1) lib/abstract_controller/rendering.rb:92:in `render'
  212. actionpack (3.0.1) lib/action_controller/metal/rendering.rb:17:in `render'
  213. actionpack (3.0.1) lib/action_controller/metal/instrumentation.rb:40:in `render'
  214. activesupport (3.0.1) lib/active_support/core_ext/benchmark.rb:5:in `ms'
  215. /usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
  216. activesupport (3.0.1) lib/active_support/core_ext/benchmark.rb:5:in `ms'
  217. actionpack (3.0.1) lib/action_controller/metal/instrumentation.rb:40:in `render'
  218. actionpack (3.0.1) lib/action_controller/metal/instrumentation.rb:78:in `cleanup_view_runtime'
  219. activerecord (3.0.1) lib/active_record/railties/controller_runtime.rb:15:in `cleanup_view_runtime'
  220. actionpack (3.0.1) lib/action_controller/metal/instrumentation.rb:39:in `render'
  221. actionpack (3.0.1) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
  222. actionpack (3.0.1) lib/action_controller/metal/mime_responds.rb:261
  223. actionpack (3.0.1) lib/action_controller/metal/mime_responds.rb:192:in `call'
  224. actionpack (3.0.1) lib/action_controller/metal/mime_responds.rb:192:in `respond_to'
  225. app/controllers/entries_controller.rb:21:in `index'
  226. actionpack (3.0.1) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
  227. actionpack (3.0.1) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
  228. actionpack (3.0.1) lib/abstract_controller/base.rb:150:in `process_action'
  229. actionpack (3.0.1) lib/action_controller/metal/rendering.rb:11:in `process_action'
  230. actionpack (3.0.1) lib/abstract_controller/callbacks.rb:18:in `process_action'
  231. activesupport (3.0.1) lib/active_support/callbacks.rb:435:in `_run__780865482__process_action__199225275__callbacks'
  232. activesupport (3.0.1) lib/active_support/callbacks.rb:409:in `send'
  233. activesupport (3.0.1) lib/active_support/callbacks.rb:409:in `_run_process_action_callbacks'
  234. activesupport (3.0.1) lib/active_support/callbacks.rb:93:in `send'
  235. activesupport (3.0.1) lib/active_support/callbacks.rb:93:in `run_callbacks'
  236. actionpack (3.0.1) lib/abstract_controller/callbacks.rb:17:in `process_action'
  237. actionpack (3.0.1) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
  238. activesupport (3.0.1) lib/active_support/notifications.rb:52:in `instrument'
  239. activesupport (3.0.1) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
  240. activesupport (3.0.1) lib/active_support/notifications.rb:52:in `instrument'
  241. actionpack (3.0.1) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
  242. actionpack (3.0.1) lib/action_controller/metal/rescue.rb:17:in `process_action'
  243. actionpack (3.0.1) lib/abstract_controller/base.rb:119:in `process'
  244. actionpack (3.0.1) lib/abstract_controller/rendering.rb:40:in `process'
  245. actionpack (3.0.1) lib/action_controller/metal.rb:133:in `dispatch'
  246. actionpack (3.0.1) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
  247. actionpack (3.0.1) lib/action_controller/metal.rb:173
  248. actionpack (3.0.1) lib/action_dispatch/routing/route_set.rb:62:in `call'
  249. actionpack (3.0.1) lib/action_dispatch/routing/route_set.rb:62:in `dispatch'
  250. actionpack (3.0.1) lib/action_dispatch/routing/route_set.rb:27:in `call'
  251. rack-mount (0.6.13) lib/rack/mount/route_set.rb:148:in `call'
  252. rack-mount (0.6.13) lib/rack/mount/code_generation.rb:93:in `recognize'
  253. rack-mount (0.6.13) lib/rack/mount/code_generation.rb:68:in `optimized_each'
  254. rack-mount (0.6.13) lib/rack/mount/code_generation.rb:92:in `recognize'
  255. rack-mount (0.6.13) lib/rack/mount/route_set.rb:139:in `call'
  256. actionpack (3.0.1) lib/action_dispatch/routing/route_set.rb:492:in `call'
  257. actionpack (3.0.1) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
  258. actionpack (3.0.1) lib/action_dispatch/middleware/head.rb:14:in `call'
  259. rack (1.2.1) lib/rack/methodoverride.rb:24:in `call'
  260. actionpack (3.0.1) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
  261. actionpack (3.0.1) lib/action_dispatch/middleware/flash.rb:182:in `call'
  262. actionpack (3.0.1) lib/action_dispatch/middleware/session/abstract_store.rb:149:in `call'
  263. actionpack (3.0.1) lib/action_dispatch/middleware/cookies.rb:287:in `call'
  264. activerecord (3.0.1) lib/active_record/query_cache.rb:32:in `call'
  265. activerecord (3.0.1) lib/active_record/connection_adapters/abstract/query_cache.rb:28:in `cache'
  266. activerecord (3.0.1) lib/active_record/query_cache.rb:12:in `cache'
  267. activerecord (3.0.1) lib/active_record/query_cache.rb:31:in `call'
  268. activerecord (3.0.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:355:in `call'
  269. actionpack (3.0.1) lib/action_dispatch/middleware/callbacks.rb:46:in `call'
  270. activesupport (3.0.1) lib/active_support/callbacks.rb:415:in `_run_call_callbacks'
  271. actionpack (3.0.1) lib/action_dispatch/middleware/callbacks.rb:44:in `call'
  272. rack (1.2.1) lib/rack/sendfile.rb:107:in `call'
  273. actionpack (3.0.1) lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
  274. actionpack (3.0.1) lib/action_dispatch/middleware/show_exceptions.rb:46:in `call'
  275. railties (3.0.1) lib/rails/rack/logger.rb:13:in `call'
  276. rack (1.2.1) lib/rack/runtime.rb:17:in `call'
  277. activesupport (3.0.1) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
  278. rack (1.2.1) lib/rack/lock.rb:11:in `call'
  279. rack (1.2.1) lib/rack/lock.rb:11:in `synchronize'
  280. rack (1.2.1) lib/rack/lock.rb:11:in `call'
  281. actionpack (3.0.1) lib/action_dispatch/middleware/static.rb:30:in `call'
  282. railties (3.0.1) lib/rails/application.rb:168:in `call'
  283. railties (3.0.1) lib/rails/application.rb:77:in `send'
  284. railties (3.0.1) lib/rails/application.rb:77:in `method_missing'
  285. railties (3.0.1) lib/rails/rack/log_tailer.rb:14:in `call'
  286. rack (1.2.1) lib/rack/content_length.rb:13:in `call'
  287. rack (1.2.1) lib/rack/handler/webrick.rb:52:in `service'
  288. /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
  289. /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
  290. /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
  291. /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
  292. /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
  293. /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
  294. /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
  295. /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
  296. /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
  297. /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
  298. rack (1.2.1) lib/rack/handler/webrick.rb:13:in `run'
  299. rack (1.2.1) lib/rack/server.rb:213:in `start'
  300. railties (3.0.1) lib/rails/commands/server.rb:65:in `start'
  301. railties (3.0.1) lib/rails/commands.rb:30
  302. railties (3.0.1) lib/rails/commands.rb:27:in `tap'
  303. railties (3.0.1) lib/rails/commands.rb:27
  304. script/rails:6:in `require'
  305. script/rails:6
Add Comment
Please, Sign In to add comment