user1466717
user1466717

Reputation: 789

Create a global variable rails 3.1

I need to create a "global" variable. I create it in the file boot.rb.

RAILS_CAR_IMAGES = Rails.root.to_s + "/app/assets/images/" unless defined?(RAILS_CAR_IMAGES)

But it pops up an error. "uninitialized constant Rails (NameError)"

Where should I create a global variable (contains path relative to the root folder) to save the uploaded images?

Upvotes: 0

Views: 340

Answers (1)

klaustopher
klaustopher

Reputation: 6941

In boot.rb Rails has not been initialized ... Create a file in config/initializers with a name like car_images.rb and put the code there

Upvotes: 1

Related Questions