Rails wice_grid with virtual class attributes

599 views Asked by At

I need to show a virtual attribute :status in my wicegrid but I always get the error that :status is not in the database .... of course its not, its virtual !

Is there a way to have a column containing a virtual attribute? and if Yes, how can I have a custom filter on that?

the model

class Shop < ActiveRecord::Base
  attr_accessor :status
end

in the view

<%= grid(@grid, upper_pagination_panel: false) do |g|
    g.column name: "Status", attribute: "status"
<% end %>
1

There are 1 answers

0
hatenine On BEST ANSWER

The documentation from Wice Grid says that it is not possible to use a virtual attribute for a column...

It is important to remember that :attribute is the name of the database column, not a model attribute. Of course, all database columns have corresponding model attributes, but not all model attributes map to columns in the same table with the same name.

Sorry i cannot help anymore, maybe someone else will answer the other half of the question.