Closed cjamison closed 13 years ago
In your app, what happens if you do Model.arel_table[:attribute_name] ?
I get nil for every attribute I try. In addition, just running Model.arel_table gives the following output:
=> #<Arel::Table:0xaa502e4 @name="model", @primary_key=nil, @table_exists=false, @table_alias=nil, @aliases=[], @columns=nil, @engine=ActiveRecord::Base>
Many thanks, Creston
That's what I expected... MetaSearch builds its conditions off of ARel attributes, and if a view doesn't provide access to its columns as an attribute, then I'm not sure there's a good solution on my end. :/
I have a rails 2 app that uses searchlogic that I am converting to rails 3 and trying to use meta-search. Everything seems to work just fine except when I try to search models that are based upon a database view. I get a variant of the following error when clicking the submit button on the search form:
The undefined method could be "matches" or "gteq" or whatever condition I am using for a field on the form. I see this on rails 3.0.7, postgresql 8.4, and pg gem 0.11.0.
Is there a simple resolution to this or is it a bit more complicated? I know there are differences in even Rails 2 to Rails 3. For example, using my database view based model in Rails 2 the command "Model.find(1)" works whereas in Rails 3 the same command results in
Interestingly, "Model.find_by_id(1)" works in both Rails 2 and Rails 3.
I would greatly appreciate any guidance in this area.