[Solved] ruby on rails – current_user on model

current_user is a devise helper to be used on Views and Controllers. If you have an instance method that needs the current_user you should probably move it’s logic to a Controller. It’s better explained here: Access to current_user from within a model in Ruby on Rails solved ruby on rails – current_user on model

[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