Ho una classe ActiveRecord chiamata Utente. Sto cercando di creare un problema chiamato Restrictable
che prende in alcuni argomenti come questo:Come creare un Rails 4 Preoccupazione che accetta un argomento
class User < ActiveRecord::Base
include Restrictable # Would be nice to not need this line
restrictable except: [:id, :name, :email]
end
Voglio quindi fornire un metodo di istanza chiamato restricted_data
che possono eseguire alcune operazioni su tali argomenti e restituire alcuni dati. Esempio:
user = User.find(1)
user.restricted_data # Returns all columns except :id, :name, :email
Come farei per farlo?