Wednesday 22 February 2017

[SOLVED] Rails multiple databases not cleaning up in tests.

So the other day I was facing this issue with Rails where the data created in a test would not get deleted from my secondary database.

The database was not cleaning up after the first test. the order didn’t matter. which ever test runs first the records created in that block were not deleted. after thorough debugging i found that there is a block inside actived record which rollsback the db. here is that block (https://github.com/rails/rails/blob/master/activerecord/lib/active_record/fixtures.rb#L1008).

 So in case of the first test the @fixture_connections count is 1 it only contains the primary db connection.

So for my secondary db I had created an abstract class SecondaryModel  which inherited from  ActiveRecord::Base 
So adding SecondaryModel.connection to test_helper solved this problem.

hope this helped!

Wednesday 11 January 2017

[SOLVED] Mac Self Assigned IP Address issue with wifi

The other day I was facing this problem while connecting to the new internet connection in my office. after searching on the interned it took me a while to fix
The solution I am going to present is same as pulling the plug but it worked for me.

So this solution worked in the below scenario for me where the router IP is not present.
click on the wifi icon => select open network preferences => click advanced => select TCP/IP

Now if you have this scenario simply follow the below steps

-- Open the finder
-- click file => Go
-- Enter '/Library/Preferences/SystemConfiguration'
-- And delete the below files (Dont worry the OS will regenerate these files but to be on safe side just move them to trash)
com.apple.airport.preferences.plist
com.apple.network.eapolclient.configuration.plist
NetworkInterfaces.plist
preferences.plist
-- Restart your computer
This worked for me. let me know if it doesn't work for you.