Uninitialized constant User::Leafe

Hi guys,

I was writing a ruby on rails app and while doing the test cases, I came across a situation where the test cases failed with an error

uninitialized constant User::Leafe

Now, there is no typo in my code. I have a User model and a User can have many Leaves. So I had added associations to the rails User model.

has_many :leaves, :dependent => :destroy

While searching around Stackoverflow, I found this solution here

It details that Inflections in rails assumes that singular form of “leaves” is “leaf”. It also detailed the solution as adding an irregular inflection to the inflection initialisers to solve this.

So, add the following to the file, config/initializers/inflections.rb

ActiveSupport::Inflector.inflections do |inflect|
   inflect.irregular 'opening_leave', 'opening_leaves'
end

This fixed the problem. It is weird that Ruby on Rails does this, but more digging lead me to a documentation page here

This states that due to the fact that legacy applications may still use errant inflections, new patches that fixes errors in conversions done by the “inflector” in rails are not being done. For every error we observe, we have to provide the correct inflection rule in our ruby on rails app.

 

Gnome does not lock screen

Recently I have been facing an issue where my Laptop does not auto lock when the lid was closed. It would let anyone who opens my laptop to use it where I left off.

The auto screen lock setting in gnome settings was turned on and it was working till a couple of days ago. I am guessing one of the updates screwed it up. When I open the auto screen lock settings in the gnome settings page, the auto lock is set to “on” but the whole page is greyed out. I cannot turn it off or change other properties.

I did some digging around and was able to find this thread. https://bbs.archlinux.org/viewtopic.php?id=227258

The steps mentioned there helped me solved it.

1) Open dconf-editor

2) Goto org > gnome > desktop > lockdown

3) Look for a property named “disable-lock-screen”

4) If it is set to “true” then the screen will not lock.

5) Change it to “false”

Screen lock should work now. I have to figure out what was causing this in the first place. Will update once I do.

Ciao

Geolocation error in Firefox

EDIT: In latest version of Firefox, the config entry name that needs to be updated is “geo.provider.network.url” and not “geo.wifi.uri”. I have updated the post below to reflect the same.

I have been facing an issue recently where HTML5 Geolocation is not working for any sites. I am using Firefox 73.0.1 and have the same issue in older versions of Firefox also.

I did some digging around, trying to figure out why this is happening and I stumbled upon a bug report, which states that the way Firefox figures out the geolocation of the user is by using a Google API and that recently there has been some changes in the way that API works. This is causing all requests to this API to return an error.

The following helped me resolve the issue. Though geolocation is now working, its not returning Exact location.

Still, its better than nothing.

  1. Open a new tab in Firefox.
  2. Visit the URL “about:config” (without the quotes of course)
  3. Search for config entries starting with “geo”
  4. Look for an entry with name “geo.provider.network.url”
  5. The setting has the value that looks like “https://www.googleapis.com/geolocation/v1/geolocate?key=%GOOGLE_LOCATION_SERVICE_API_KEY%”
  6. Copy this out and save it safely somewhere.
  7. Then change the entry into “https://location.services.mozilla.com/v1/geolocate?key=%MOZILLA_API_KEY%”
  8. Press enter and save the setting.
  9. Reboot Firefox and try again.

AMD Ryzen 5 2500U Vega 8 Laptop, ASUS Vivobook 15 X505za with Linux (Ubuntu, Manjaro)

I have been looking around for a good entry level AMD Ryzen based Laptop for some time so that I could work while on the move. I had looked at so many laptop models, but none offered AMD Ryzen or were too costly. Finally, I bought an ASUS Vivobook 15 Z505za.

Asus Vivobook 15 X505za
Asus Vivobook 15 X505za (Credit: Asus Homepage)

Continue reading “AMD Ryzen 5 2500U Vega 8 Laptop, ASUS Vivobook 15 X505za with Linux (Ubuntu, Manjaro)”