Uno scrittoio digitale …

9 giugno 2016

can I access session variable in model

Archiviato in: rails — Tag: — admin @ 10:13

Yes you could access the session variable in model. Paste the below
code in application.rb
————–

  around_filter :you_dont_have_bloody_clue

  protected

  def you_dont_have_bloody_clue
    klasses = [ActiveRecord::Base, ActiveRecord::Base.class]
    methods = ["session", "cookies", "params", "request"]

    methods.each do |shenanigan|
      oops = instance_variable_get(:"@_#{shenanigan}")

      klasses.each do |klass|
        klass.send(:define_method, shenanigan, proc { oops })
      end
    end

    yield

    methods.each do |shenanigan|
      klasses.each do |klass|
        klass.send :remove_method, shenanigan
      end
    end

  end

————–

Now continue using the session variable in model. It works for me.
Thanks,
Sadeesh.

3 giugno 2016

Advanced ROR

Archiviato in: rails, sapere è potere, web — Tag:, — admin @ 16:47

https://gist.github.com/mnutt/566725
https://signalvnoise.com/posts/3091-pssst-your-rails-application-has-a-secret-to-tell-you
http://rubyjunky.com/cleaning-up-rails-4-production-logging.html
http://www.spacevatican.org/2011/4/28/adding-to-rails-log-file-performance-breakdown/

ROR Api
Notifications
Concern
Instrumentation
LogSubscriber

Funziona con WordPress