草庐IT

Namespace

全部标签

ruby-on-rails - autoload_paths 不知道 namespace ?

在app/services中,我有一些类,如Notification::Finder和Notification::Builder。它们被放置为app/services/notification/builder.rb和app/services/notification/finder.rb。还有Notification类作为模型,位于app/models/notification.rbautoload_path配置为config.autoload_paths+=%W(#{config.root}/app/services)当我尝试加载Finder时,它起作用了:Loadingdevelop

ruby - HABTM 链接表未在可安装引擎中采用 isolate_namespace 值

我目前正在开发一个可安装的引擎。在引擎中,我有以下两个模型:moduleEmsclassChannel这些是数据库迁移文件:classCreateEmsChannelsfalsedo|t|t.integer:category_id,:null=>falset.integer:channel_id,:null=>falseend#Addtableindexadd_index:ems_categories_channels,[:category_id,:channel_id],:unique=>trueendend当我尝试检索关联的对象时,问题就开始了。例如,当我调用@channel.ge

ruby-on-rails - Ruby on Rails 路由 : Namespace with more params

我有一个命名空间“shop”。在那个命名空间中,我有一个资源“新闻”。namespace:shopdoresources:newsend我现在需要的是,我的“新闻”路由可以获得一个新参数:/shop/nike(landingpage->goesto"news#index",:identifier=>"nike")/shop/adidas(landingpage->goesto"news#index",:identifier=>"adidas")/shop/nike/news/shop/adidas/news这样我就可以得到商店并过滤我的新闻。我需要这样一条路线:/shop/:ident

ruby-on-rails - Rails : After putting devise routes in namespace, 模型名称以命名空间为前缀。如何删除它?

我在我的RailsRESTFulAPI服务中使用devise进行身份验证。Devise使我能够使用[POST]http://domain/users和form_data创建一个新用户:[user]password=123[user]email=foo@bar.zoo[user]password_confirmation=123然后我将devise_for放在这样的命名空间中namespace:apidonamespace:v1dodevise_for:users,controllers:{:registrations=>'api/v1/registrations',:sessions=

c++ - 如何将枚举导入 C++ 中的不同命名空间?

我在命名空间中有一个枚举,我想像在不同的命名空间中一样使用它。直觉上,我认为我可以使用“使用”或“类型定义”来完成此操作,但实际上都不起作用。证明它的代码片段,在GCC和SunCC上测试:namespacefoo{enumbar{A};}namespacebuzz{//WhichofthesetwomethodsIusedoesn'tmatter,//theresultsarethesame.usingfoo::bar;//typedeffoo::barbar;}intmain(){foo::barf;//worksfoo::barg=foo::A;//worksbuzz::barx;

c++ - 如何将枚举导入 C++ 中的不同命名空间?

我在命名空间中有一个枚举,我想像在不同的命名空间中一样使用它。直觉上,我认为我可以使用“使用”或“类型定义”来完成此操作,但实际上都不起作用。证明它的代码片段,在GCC和SunCC上测试:namespacefoo{enumbar{A};}namespacebuzz{//WhichofthesetwomethodsIusedoesn'tmatter,//theresultsarethesame.usingfoo::bar;//typedeffoo::barbar;}intmain(){foo::barf;//worksfoo::barg=foo::A;//worksbuzz::barx;

整个类范围内的 C++ 命名空间别名

我希望能够在类声明中使用命名空间别名,但出现编译器语法错误。structMyClass{namespaceabc=a_big_namespace;voidfn(){abc::test();}};我可以让它工作的唯一方法是将别名放在每个函数中。voidfn(){namespaceabc=a_big_namespace;abc::test();}此外,我希望能够将别名用于函数参数。我还没有找到解决方法。voidfn(abc::testTypett){abc::test(tt);}有没有办法做我想做的事?编辑:我的解决方案我发现我不需要未命名的命名空间来解决我的特定问题,并且可以简单地这样做

整个类范围内的 C++ 命名空间别名

我希望能够在类声明中使用命名空间别名,但出现编译器语法错误。structMyClass{namespaceabc=a_big_namespace;voidfn(){abc::test();}};我可以让它工作的唯一方法是将别名放在每个函数中。voidfn(){namespaceabc=a_big_namespace;abc::test();}此外,我希望能够将别名用于函数参数。我还没有找到解决方法。voidfn(abc::testTypett){abc::test(tt);}有没有办法做我想做的事?编辑:我的解决方案我发现我不需要未命名的命名空间来解决我的特定问题,并且可以简单地这样做

c++ - 如何避免vim中的命名空间内容缩进?

如何在C++中设置vim不缩进命名空间内容?namespace{//Unwantedindentation}令人惊讶的是,'cinoptions'不提供编辑命名空间内容缩进的方法。 最佳答案 不确定何时引入,但我安装的vim版本v7.3.353有一个cino选项,可以显式处理cpp命名空间。我目前正在使用示例值:cino=N-s并根据:helpcinoptions-valuesNNIndentinsideC++namespaceNcharactersextracomparedtoanormalblock.(default0).cin

c++ - 如何避免vim中的命名空间内容缩进?

如何在C++中设置vim不缩进命名空间内容?namespace{//Unwantedindentation}令人惊讶的是,'cinoptions'不提供编辑命名空间内容缩进的方法。 最佳答案 不确定何时引入,但我安装的vim版本v7.3.353有一个cino选项,可以显式处理cpp命名空间。我目前正在使用示例值:cino=N-s并根据:helpcinoptions-valuesNNIndentinsideC++namespaceNcharactersextracomparedtoanormalblock.(default0).cin