[Solved] Resolve Fixnum error [closed]

You are calling the employee_id method on authorization_selectedwhich is a String and does not provide this method. Obviously this does not work. You probably want to do @portability = Portability.new @portability.employee_id = authorization_selected assuming that params[:employee] contains the employee_id and Portability is an ActiveModel or an ActiveRecord. Perhaps you can change your form that the … Read more

[Solved] hash inside liste of hash extracted from array [closed]

I’m not sure what exactly you want to do, but you can try the following: arr = [“Japan”, “Egypt”, “Spain”, “Brazil”] arr.each { |a| Object.const_set(a, Hash.new(a)) } #initialize hashes Country = arr.map {|a| [a, 0]}.to_h #=> {“Japan”=>0, “Egypt”=>0, “Spain”=>0, “Brazil”=>0} or Country = Hash[arr.map {|a| [a, 0]}] #=> {“Japan”=>0, “Egypt”=>0, “Spain”=>0, “Brazil”=>0} Note: Ruby variables … Read more

[Solved] username regex in rails 4 [closed]

You could use this regex: ^(\w|\.)+$ Which is the same as: ^[a-zA-Z0-9_\.]+$ Here’s preview of the regex in action on regex101.com, and here’s a breakdown of it ^ matches the beginning of the string ( just groups the characters so a modifier can be applied \w matches any character that is a-z, A-Z, 0-9, and … Read more

[Solved] Ruby on Rails variables, object attributes, and methods that use a : before or after them

:symbol {key: value} When the colon is before the variable / object, it denotes a “symbol”, meaning a piece of data to be placed there. The symbol can typically be used in the likes of calling an attribute (key) or in part of a hash: @user.comment[:created_at] When the colon is after the variable / object, … Read more

[Solved] ruby on rails 4/jquery/javascript: button only works after page reload

Line 433 of http://new.mapmill.org:3000/assets/sites.js $(‘#upload_more’).click(function() { return window.location.href=”https://stackoverflow.com/sites/” + $(‘#site_id’).val() + “/upload”; }); You are binding the event handler on DOM ready, but your page content is loaded dynamically. So at the time you binding the event, $(‘#upload_more’) doesn’t even exist in the DOM. In my experences this is commonly happened when someone is developing … Read more