Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rails 0.65 KB | None | 0 0
  1. class AlfaData < ActiveRecord::Base
  2.   belongs_to :alfa
  3.  
  4.   def before(what)
  5.     self.send( "#{what}_fรถre" )
  6.   end  
  7. end
  8.  
  9. -----
  10. module ApplicationHelper
  11.   def icontable( ds1, ds2, names )
  12.     alfa = ""
  13.     Mci.new.send( names ).each do |v|
  14.       alfa += iconbox(v, ds1.send(v), ds2.send(v)) unless ['kampanj'].include?(v)
  15.     end
  16.     return alfa
  17.   end
  18. end
  19. -----
  20. erb:
  21.  
  22. icontable( ds1.method(:before), ds1.method(:after), 'pres' )
  23.  
  24. ----
  25.  
  26. Controller:
  27. ds1=Alfa.first.dataset
  28. ds2=Alfa.last.dataset
  29.  
  30. ---
  31.  
  32. Previously this was in the model too:
  33.  
  34.   def after(&block)
  35.     lambda { |what| self.send( "#{what}_efter" ) }
  36.   end
  37.  
  38. didn't work either
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement