Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to unload the files loaded by the "require" statement in rails

I have bunch of classes

files = ["payment_type","payment_type_ticket_mapping","price_modifier_ticket_delta_mapping","user","revenue_type","revenue_type_group","tax","tax_type","punch"]
files.each {|file| require file }

that are required to fulfill the requirement of Marshal.load but when I run the rsepc they give me the following error

/spec/factories.rb:6: undefined method `admin_login_url' for #<ActionView::Base:0xb62e0228> (ActionView::TemplateError)

When I remove that reuire statement it works fine but that statement is necessary for the functionality of Marshal.load how to unload the loaded classes by require statement after the work is done.

like image 525
Anup Pareek Avatar asked Nov 21 '25 01:11

Anup Pareek


1 Answers

I have resolved that problem using the config.cache_classes = true in the environment.

like image 81
Anup Pareek Avatar answered Nov 22 '25 14:11

Anup Pareek