vimal
2009-Mar-09 06:02 UTC
Importing application constants into models and backgroundrb workers - How To?
Hi, I have an app_constants.rb file for defining my constants. I need the same constants for checking conditions with my models and backgroundrb workers. When i tried require "app_constants" in my models files it doesn''t suggest any errors but i was unable to use the constants either Any suggestions??? Regards, Vimal Das --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
MaD
2009-Mar-09 07:36 UTC
Re: Importing application constants into models and backgroundrb workers - How To?
requiring your file should make them available for your models. there is something wrong with your code. # file.rb CONSTANT = "loaded" # some_model.rb class SomeModel < ActiveRecord::Base require File.dirname(__FILE__) + ''/some/path/to/your/file'' def self.constant_status puts CONSTANT end end # script/console>> SomeModel::constant_statusloaded => nil --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
vimal
2009-Mar-09 08:23 UTC
Re: Importing application constants into models and backgroundrb workers - How To?
Cool.Thank you. :) Vimal Das --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---