开发者

NoMethodError in rails

开发者 https://www.devze.com 2023-01-04 02:58 出处:网络
The extracted source is below : Showing /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/templates/rescues/diagnostics.erbwhere line # raised:

The extracted source is below :

Showing /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/templates/rescues/diagnostics.erb where line # raised:

private method `gsub' called for #<NoMethodError: undefined method `closed?' for nil:NilClass>

Extracted source (around line #):

RAILS_ROOT: /home/sharath/Desktop/RORWorkspace/ITPLOW1

It was working before installing 开发者_如何学编程Sunspot: A Solr-Powered Search Engine for Ruby.

I am working in Ubuntu 10.04.


I'd need to see the full stacktrace to be sure, but this is actually probably an unhelpful HTTP connection error message bubbling up out of RSolr (the library the Sunspot uses for the low-level Solr connection). Is Solr running (i.e., did you run rake sunspot:solr:start)? Can you access http://localhost:8982/solr/admin ?


What's probably happening is you're attempting to do a substitution on some variable which you thought you were initializing, but neglected to give a real value.

For instance, if you had a form where for a Message and one of the the properties you want is the content, you would normally retrieve that information in the controller with

params[:message][:content]

And if you wanted to filter it, you would do something like

params[:message][:content].gsub(/<[^>]*>/,"")

But if the user didn't enter anything into the content field, the params[:message][:content] variable wouldn't be set. Therefore it's null and you're attempting to do nil.gsub

0

精彩评论

暂无评论...
验证码 换一张
取 消