berk / will_filter

rails engine plugin for filtering active_record model objects
MIT License
157 stars 76 forks source link

Replace *_id associations with names #12

Closed tonymarschall closed 12 years ago

tonymarschall commented 12 years ago

I want to customize the result and display user.name instead of task.user_id. Is this possible?

tonymarschall commented 12 years ago

I found https://github.com/berk/will_filter/blob/master/app/models/will_filter/filter.rb

Its possible to set the table name via condition_title_for method

class TimeentryFilter < WillFilter::Filter

  def condition_title_for(title_key)
    if title_key == :"user_id"
      return :"User"
    end
    return title_key
  end
...

How can i reference user_id:1 to user.name in the resultset?

tonymarschall commented 12 years ago

Found a example on howto customize the table output:

https://github.com/berk/tr8n/blob/master/app/views/tr8n/admin/language/index.html.erb