I am trying to create an ActiveRecord model called ‘Search’ without a table. I keep getting this error when I do @search = Search.new.
sql::Error: Table ‘searchdemo_development.tablelesses’ doesn’t exist: SELECT * FROM tablelesses
I am using the idea from this comment: Rails model without database. I also get the same kind of error doing the basic:
class Search < ActiveRecord::Base
end
How do I get ActiveRecord stop looking for a table?
I can think of a few reasons you might want to do something like this. Perhaps you want to leverage some of the non-db-related methods on ActiveRecord or you want to pass your object to something that expects and ActiveRecord instance. Without more info, it is impossible to say whether the choice to use AR here is correct or incorrect.
In any event, if you want to continue on this path…
check out this Railscast
http://railscasts.com/episodes/121-non-active-record-model
and also checkout this gem:
http://github.com/kennethkalmer/activerecord-tableless-models/tree/master