我正在一个大型rails项目中工作,我有一些文件:
app/services/my_service/my_action/my_model_2.rb:
module <my_service>
module <my_action>
class <my_model_2>
. . .
if some_var = <my_model>::MY_CONST
if some_Var = ::<my_model>::MY_CONST # <-- what is the difference here?
Run Code Online (Sandbox Code Playgroud)
app/services/my_service/my_action/my_model.rb:
module <my_service>
module <my_action>
class <my_model>
Run Code Online (Sandbox Code Playgroud)
app/services/my_service/my_model.rb:
module <my_service>
class <my_model>
Run Code Online (Sandbox Code Playgroud)
app/models/my_model.rb:
class <my_model> < ActiveRecord::Base
. . .
MY_CONST = "my constant"
Run Code Online (Sandbox Code Playgroud)
my_model_2.rb有什么区别?
如何从my_model_2.rb正确访问每个模型的范围?
请注意,app/models类名与app/services类名相同.
我试图摆脱我的"未提交的更改",我的Gemfile.lock不断重新出现作为一个非暂存文件.我相信这是因为我更新了bundler,因为更改是:
-
- BUNDLED WITH
- 1.10.5
Run Code Online (Sandbox Code Playgroud)
首先,这些不起作用,因为Gemfile.lock会更新自己:
git checkout -- Gemfile.lock
git stash save --keep-index --include-untracked
git stash drop
git reset HEAD
git clean -df
git checkout -- .
Run Code Online (Sandbox Code Playgroud)
有用的是:
git update-index --assume-unchanged Gemfile.lock
Run Code Online (Sandbox Code Playgroud)
看起来没问题,运行"git status":
On branch develop
Your branch is up-to-date with 'origin/develop'.
nothing to commit, working directory clean
Run Code Online (Sandbox Code Playgroud)
我无法运行"git checkout origin/existing_branch"
error: Your local changes to the following files would be overwritten by checkout:
Gemfile.lock
Please, commit your changes or stash them before you can switch …Run Code Online (Sandbox Code Playgroud)