Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Model Name Conflict

I have a model by the name Filter but due to the changes in reorganizing the filters from 2.0.3, it is conflicting with the

ActionController::Filters::Filter (class)

In my filters_controller.rb when I try to find the filter

Filter.find(:id)

as rails is infering the ActionController::Filters::Filter class rather than my model class Filter. Is there any work around other than renaming my model?

BTW: If I use ActiveRecord::Base::Filter.find(:id) to load my filter object, its working, but I am not quite sure if there are any unforseen implications by doing this, when rails try to unload/reload constants.

Thanks in advance.


2 Answers

The safest way to deal with this is to rename your model. Otherwise you run the risk of being 'clever' and getting bitten by this later when it will be very difficult to debug.

like image 151
Kevin Avatar answered Jan 04 '26 04:01

Kevin


I almost missed your comment, so to answer your own question.

::Filter.find()
like image 21
Eddie Avatar answered Jan 04 '26 02:01

Eddie



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!