Constant definition in Ruby/RailsHow can I “pretty” format my JSON output in Ruby on Rails?How to get a random number in RubyA concise explanation of nil v. empty v. blank in Ruby on RailsUnderstanding the Rails Authenticity TokenHow to write a switch statement in RubyCheck if a value exists in an array in RubyHow can I rename a database column in a Ruby on Rails migration?How do I get the current absolute URL in Ruby on Rails?Ruby on Rails Server optionsWhat is attr_accessor in Ruby?
Prove that NP is closed under karp reduction?
Theorem, big Paralist and Amsart
Python: next in for loop
What typically incentivizes a professor to change jobs to a lower ranking university?
What is the offset in a seaplane's hull?
The use of multiple foreign keys on same column in SQL Server
Why are electrically insulating heatsinks so rare? Is it just cost?
Theorems that impeded progress
Do VLANs within a subnet need to have their own subnet for router on a stick?
What does "Puller Prush Person" mean?
How can I make my BBEG immortal short of making them a Lich or Vampire?
How can bays and straits be determined in a procedurally generated map?
Have astronauts in space suits ever taken selfies? If so, how?
How to test if a transaction is standard without spending real money?
Writing rule stating superpower from different root cause is bad writing
Risk of getting Chronic Wasting Disease (CWD) in the United States?
Which models of the Boeing 737 are still in production?
Minkowski space
How to say job offer in Mandarin/Cantonese?
Mathematical cryptic clues
"You are your self first supporter", a more proper way to say it
Why not use SQL instead of GraphQL?
Today is the Center
Why can't I see bouncing of a switch on an oscilloscope?
Constant definition in Ruby/Rails
How can I “pretty” format my JSON output in Ruby on Rails?How to get a random number in RubyA concise explanation of nil v. empty v. blank in Ruby on RailsUnderstanding the Rails Authenticity TokenHow to write a switch statement in RubyCheck if a value exists in an array in RubyHow can I rename a database column in a Ruby on Rails migration?How do I get the current absolute URL in Ruby on Rails?Ruby on Rails Server optionsWhat is attr_accessor in Ruby?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I have initializers config
in my rails application under config/initializers/my_config.rb
.
What is the difference between:
A:
module MyModule
Config = "path/to/config.yml"
end
and:
B:
MyModule::Config = "path/to/config.yml"
Let's suppose we do some requests, change its implementation, and hit the application again. If I defined my constant the B way, I get an error:
uninitialized constant MyModule::Config
It will be resolved only when I restart my rails server. But when I do the A way, it still recognized the constant when I updated my code.
What is the importance of using the A syntax in this case?
ruby-on-rails ruby
add a comment |
I have initializers config
in my rails application under config/initializers/my_config.rb
.
What is the difference between:
A:
module MyModule
Config = "path/to/config.yml"
end
and:
B:
MyModule::Config = "path/to/config.yml"
Let's suppose we do some requests, change its implementation, and hit the application again. If I defined my constant the B way, I get an error:
uninitialized constant MyModule::Config
It will be resolved only when I restart my rails server. But when I do the A way, it still recognized the constant when I updated my code.
What is the importance of using the A syntax in this case?
ruby-on-rails ruby
add a comment |
I have initializers config
in my rails application under config/initializers/my_config.rb
.
What is the difference between:
A:
module MyModule
Config = "path/to/config.yml"
end
and:
B:
MyModule::Config = "path/to/config.yml"
Let's suppose we do some requests, change its implementation, and hit the application again. If I defined my constant the B way, I get an error:
uninitialized constant MyModule::Config
It will be resolved only when I restart my rails server. But when I do the A way, it still recognized the constant when I updated my code.
What is the importance of using the A syntax in this case?
ruby-on-rails ruby
I have initializers config
in my rails application under config/initializers/my_config.rb
.
What is the difference between:
A:
module MyModule
Config = "path/to/config.yml"
end
and:
B:
MyModule::Config = "path/to/config.yml"
Let's suppose we do some requests, change its implementation, and hit the application again. If I defined my constant the B way, I get an error:
uninitialized constant MyModule::Config
It will be resolved only when I restart my rails server. But when I do the A way, it still recognized the constant when I updated my code.
What is the importance of using the A syntax in this case?
ruby-on-rails ruby
ruby-on-rails ruby
edited Mar 22 at 10:50
chumakoff
4,13911233
4,13911233
asked Mar 21 at 23:51
Kris MPKris MP
56811024
56811024
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Part of this seems to have to do with rails hot code reloading, which has a bunch of caveats. If you aren't using hot code reloading, A and B are more equivalent, as long as MyModule
has been defined first.
However, when code is reloaded, (particularly the file that defines MyModule
), it might end up overwriting the existing module, and not running the B line.
The main difference though, is that A doesn't rely on how the order of other code in the project is loaded/run, but B must be run after certain code.
add a comment |
The differences is that code A raises a syntax error, while code B is grammatical. Code B will raise a name error for MyModule
unless it is previously defined, though.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55290889%2fconstant-definition-in-ruby-rails%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Part of this seems to have to do with rails hot code reloading, which has a bunch of caveats. If you aren't using hot code reloading, A and B are more equivalent, as long as MyModule
has been defined first.
However, when code is reloaded, (particularly the file that defines MyModule
), it might end up overwriting the existing module, and not running the B line.
The main difference though, is that A doesn't rely on how the order of other code in the project is loaded/run, but B must be run after certain code.
add a comment |
Part of this seems to have to do with rails hot code reloading, which has a bunch of caveats. If you aren't using hot code reloading, A and B are more equivalent, as long as MyModule
has been defined first.
However, when code is reloaded, (particularly the file that defines MyModule
), it might end up overwriting the existing module, and not running the B line.
The main difference though, is that A doesn't rely on how the order of other code in the project is loaded/run, but B must be run after certain code.
add a comment |
Part of this seems to have to do with rails hot code reloading, which has a bunch of caveats. If you aren't using hot code reloading, A and B are more equivalent, as long as MyModule
has been defined first.
However, when code is reloaded, (particularly the file that defines MyModule
), it might end up overwriting the existing module, and not running the B line.
The main difference though, is that A doesn't rely on how the order of other code in the project is loaded/run, but B must be run after certain code.
Part of this seems to have to do with rails hot code reloading, which has a bunch of caveats. If you aren't using hot code reloading, A and B are more equivalent, as long as MyModule
has been defined first.
However, when code is reloaded, (particularly the file that defines MyModule
), it might end up overwriting the existing module, and not running the B line.
The main difference though, is that A doesn't rely on how the order of other code in the project is loaded/run, but B must be run after certain code.
answered Mar 22 at 0:04
Garrett MotznerGarrett Motzner
823315
823315
add a comment |
add a comment |
The differences is that code A raises a syntax error, while code B is grammatical. Code B will raise a name error for MyModule
unless it is previously defined, though.
add a comment |
The differences is that code A raises a syntax error, while code B is grammatical. Code B will raise a name error for MyModule
unless it is previously defined, though.
add a comment |
The differences is that code A raises a syntax error, while code B is grammatical. Code B will raise a name error for MyModule
unless it is previously defined, though.
The differences is that code A raises a syntax error, while code B is grammatical. Code B will raise a name error for MyModule
unless it is previously defined, though.
answered Mar 22 at 7:33
sawasawa
1
1
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55290889%2fconstant-definition-in-ruby-rails%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown