草庐IT

as-patterns

全部标签

ruby-on-rails - rails : attr_accessor doesn't show up when try to render as JSON

在我的应用程序中,我有一个模型如下;classInit在这里,当我稍后添加了**attr_accessor**并尝试应用**renderjson:init**时,它不显示**clientAvailability**属性,即使我已经设置它作为;init=Init.newinit.clientAvailability="3"当我调试它时,我可以看到它已设置,但当我尝试将它呈现为json时,它并没有简单地显示出来。我可能遗漏了什么? 最佳答案 clientAvailability是数据库中的一列吗?如果没有,那么我认为这是默认方式-仅序列

ruby-on-rails - 带有 acts-as-taggable-on 的简单表单自定义输入

我在使用Simple_form和acts-as-taggable-on时遇到了一些问题。我有一个对象“象形图”,带有一些标签,例如“门”和“紧急情况”我在我的表单中使用了这段代码=f.input:tag_list当我编辑我的象形图时,系统会删除我的逗号并显示我的text_field就像“门紧急情况”,如果我保存我的两个标签被删除并替换为一个标签“门紧急情况”我正在网上寻找解决方案,许多人建议在simple_form中创建自定义输入,但我不知道从哪里开始。我在app/inputs中创建了一个文件tag_input.rb并添加了这段代码classTagInput但现在我迷路了。对不起我的英

css - gulp-ruby-sass : 'bundle' is not recognized as an internal or external command, 可运行程序或批处理文件

我正在尝试在Windows上运行gulp-ruby-sass。我收到以下错误:gulp-ruby-sass:'bundle'isnotrecognizedasaninternalorexternalcommand,operableprogramorbatchfile.我已经在我的c:\驱动器(c:\Ruby193)上成功安装了ruby​​我还安装了SaSSgeminstallsass(从这里执行c:\Ruby193)windows我也设置了注册路径c:\ruby193我正在从c:\project\transformer\作为gulp运行我的gulp我仍然收到此错误:gulp-ruby-

ruby-on-rails - 确定 Journey::Path::Pattern 是否匹配当前页面

我正在尝试使用概述的方法thispost结合url_for来确定当前路径是否在已安装的引擎中,但我很难弄清楚如何使用Journey::Path::Pattern(这是另一篇文章中概述的mounted_pa​​th方法返回的内容)。classRails::Enginedefself.mounted_pathroute=Rails.application.routes.routes.detectdo|route|route.app==selfendroute&&route.pathendend除了theofficialdocumentation,似乎没有太多关于它的讨论。,这不是特别有用。

ruby-on-rails - rails : Subclass not registering as instance of parent class

在我正在使用的Rails应用程序中,我有如下代码:#app/models/a.rbclassA当我在本地运行它时,它按预期执行并且我得到“notnil”作为返回值。但是我在我的测试环境中得到了nil。测试环境显示A是letter(B.new)的祖先(B.ancestors)code>),但无法使用大小写相等运算符或is_a?(A)注册为子类。A===B.new#=>falseintestenvironment,truelocallyB.new.is_a?(A)#=>falseintestenvironment,truelocally这似乎是一个Rails自动加载问题,但我不确定如果父类

ruby - Rails 3 Authlogic - 'acts_as_authentic' 未定义

我收到以下错误:NameError(undefinedlocalvariableormethod`acts_as_authentic'for#):app/models/user.rb:2app/controllers/user_controller.rb:3:in`new'我正在使用Rails3.0.0和Ruby1.8.7。Authlogic在我的Gemfile中如下:gem'authlogic',:git=>"git://github.com/binarylogic/authlogic.git"我的User.rb文件的全部内容如下:classUser无论是通过“railsconsol

ruby - 使用 issue_closing_pattern 变量关闭 gitlab 中的多个问题

我希望能够通过使用默认模式引用多个问题来通过一次提交关闭多个问题^([Cc]loses|[Ff]ixes)+#\d+a。我知道这只会影响行首的fixes#number-patterns,这就是我想要的。但我还不能让它工作。我目前正在使用Gitlab6.1,根据github上的安装自述文件安装它,除了下面的代码片段之外没有做任何更改。这是我尝试过的:首先,我在{gitlab-directory}/app/models/commit.rb中进行了更改thefollowing(原代码被注释掉):defcloses_issuesprojectmd=safe_message.scan(/(?i)

ruby-on-rails - rails 协会 :autosave doesn't seem to working as expected

我做了一个真正的基础github项目here这说明了这个问题。基本上,当我创建一个新评论时,它会按预期保存;当我更新现有评论时,它不会被保存。然而,这不是:autosave=>true的文档所说的……他们说的恰恰相反。这是代码:classPosttrue,:inverse_of=>:post,:dependent=>:destroydefcomment=(val)obj=comments.find_or_initialize_by(:posted_at=>Date.today)obj.text=valendendclassComment:commentsend现在在控制台中,我测试:p

ruby-on-rails - acts_as_tree 不会破坏模型的 child

我有这个任务模型:classTask'sort_order'end我有这个测试classTaskTest@root.id,:sort_order=>2)d2=create_task(:parent_id=>d1.id,:sort_order=>3)d3=create_task(:parent_id=>d2.id,:sort_order=>4)d4=create_task(:parent_id=>d1.id,:sort_order=>5)assert_equal5,Task.countd1.destroyassert_equal@root,Task.find(:first)assert_

ruby-on-rails - Rails 的 act_as 背后的基本概念是什么?

我好像找不到这个问题的答案,我有点看到它通过实现做了什么,但不理解它的意义.. 最佳答案 YehudaKatz有一个niceexplanationacts_as插件模式的定义以及为什么它通常以不必要的复杂方式实现。 关于ruby-on-rails-Rails的act_as背后的基本概念是什么?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/1811090/