So I ran into a problem that took me a ridiculously long time to figure out... In fact I didn't really figure it out myself... It took listening to my tutor read the code back to me, before the penny dropped what the problem was. For ages I was getting the following error
SQLite3::SQLException: no such column: name: SELECT "events".* FROM "events" WHERE (name LIKE '%f%')
I checked the tutorial we'd been given, I checked all the examples I could find on the web and nothing helped I kept getting the same error. Despite having this method in the model
def self.search(search_query)
if search_query
find(:all, :conditions => ['name LIKE ?', "%#{search_query}%"])
else
find(:all)
end
end
and this controller talking to it
def index
@events = Event.search(params[:search_query])
#respond_to do |format|
#format.html # index.html.erb
#format.xml { render :xml => @events }
#end
end
However I really should have read the error message clearer as the clue was in the message. It kept telling me that there was no such column name. and it was right. there was not such column name, my column was called title. So I changed that one little word and everything is dandy again. Learnt a very valuable lesson though - Read the error messages carefully.
SQLite3::SQLException: no such column: name: SELECT "events".* FROM "events" WHERE (name LIKE '%f%')
I checked the tutorial we'd been given, I checked all the examples I could find on the web and nothing helped I kept getting the same error. Despite having this method in the model
def self.search(search_query)
if search_query
find(:all, :conditions => ['name LIKE ?', "%#{search_query}%"])
else
find(:all)
end
end
and this controller talking to it
def index
@events = Event.search(params[:search_query])
#respond_to do |format|
#format.html # index.html.erb
#format.xml { render :xml => @events }
#end
end
However I really should have read the error message clearer as the clue was in the message. It kept telling me that there was no such column name. and it was right. there was not such column name, my column was called title. So I changed that one little word and everything is dandy again. Learnt a very valuable lesson though - Read the error messages carefully.
Blog Archive