the problem is this line :
@feature_products = Setting.first.features.where("product_id is not null")
here you call features
method on Setting.first
, and you get the error because Setting.first return nil (which means your settings table is empty for now), calling features method on Setting.first in this case is like calling : nil.features
some persons suggest you to fill in your database rows, but i think this is not really the way to solve this, any app should be working without any existing data
to solve the above bug you should just add a condition like this :
@feature_products = Setting.first.features.where("product_id is not null") unless Setting.first.nil?
or use try method :
@feature_products = Setting.first.try(:features).where("product_id is not null")
Hope this help