Re: [Rails] ActiveRecord Extension With Different Tables

2016-10-15 Thread nanaya
Hi, On Sat, Oct 15, 2016, at 22:10, Usman Shahid wrote: > Actually these tables and models are dynamically added to the database, > every addition requires creating a new model in the system which contains > nothing but the table name. I'm trying to avoid that by creating a single > model which ca

Re: [Rails] ActiveRecord Extension With Different Tables

2016-10-15 Thread Usman Shahid
Actually these tables and models are dynamically added to the database, every addition requires creating a new model in the system which contains nothing but the table name. I'm trying to avoid that by creating a single model which can handle multiple tables given a table name using ActiveRecord qu

Re: [Rails] ActiveRecord Extension With Different Tables

2016-10-15 Thread Greg Navis
What Colin said. Alternatively, you could write a concern and include it in models you want to support in the search feature. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it

Re: [Rails] ActiveRecord Extension With Different Tables

2016-10-15 Thread Colin Law
On 15 October 2016 at 10:07, Usman Shahid wrote: > I cannot find an alternative to this. What i'm trying to do is write a > generic interface which can answer generic queries like search based on > specific column and aggregate queries etc. Underlying table is provided to > the Model on initializ

Re: [Rails] ActiveRecord Extension With Different Tables

2016-10-15 Thread Usman Shahid
I cannot find an alternative to this. What i'm trying to do is write a generic interface which can answer generic queries like search based on specific column and aggregate queries etc. Underlying table is provided to the Model on initialization and I want it hooked with that table so that I can ru

Re: [Rails] ActiveRecord Extension With Different Tables

2016-10-14 Thread Greg Navis
Probably doable (hackable) but I think it’d be extremely unidiomatic Rails. If you could tell us what you’re trying to achieve we might be able to suggest a better solution. Cheers Greg -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. T

[Rails] ActiveRecord Extension With Different Tables

2016-10-14 Thread Usman Shahid
Hi, Is it possible in rails to write a generic ActiveRecord::Base child class which is bound with a table of our choice on runtime? for example if it has two functions 'foo' and 'bar' then i should be able to provide a table name on runtime e.g. 'table-a' or 'table-b' and execute these functions o