dimanche 16 novembre 2014

Ruby on Rails, including a module with arguments


Vote count:

0




Is there a way to use arguments when including a ruby module? I have a module Assetable which is included across many classes. I want to be able to generate attr_accessor's on the fly.



module Assetable
extend ActiveSupport::Concern

included do
(argument).times do |i|
attr_accessor "asset_#{i}".to_sym
attr_accessible "asset_#{i}".to_sym
end
end
end


asked 15 secs ago







Ruby on Rails, including a module with arguments

Aucun commentaire:

Enregistrer un commentaire