我有这个奇怪的问题,如果我这样做:
namespace :xaaron do
task :get_roles do
roles = Xaaron::Role.all
puts roles
end
task :get_role, [:name] do |t, args|
role = Xaaron::Role.find(args[:name].parameterize)
puts role
end
end
Run Code Online (Sandbox Code Playgroud)
第一项任务将完美无缺.我甚至可以放在binding.pry一边做,Xaaron::Role并获得有关角色的信息.但第二项任务爆炸说明NameError: uninitialized constant Xaaron::Role
我在我的主应用程序中运行每个任务(因为这些任务在引擎内)为:bin/rake xaaron:get_roles和bin/rake xaaron:get_role.
为什么第二个爆炸但第一个不爆炸?是否存在争论的事情?
更新
我应该注意,我可以bin/rails c在使用所述引擎的主应用程序中执行,Xaaron::Role并获取有关Roles表的信息.
我有一个表单元素:
<%= f.collection_select :race, :id, Race.all, :id, :name, prompt: true %>
这允许您在我正在创建的文本冒险中选择您的角色竞赛.目标是让所有可用的比赛下拉,按名称选择并让params传回该比赛的id.
但是当我加载页面时,我得到了undefined method 'merge' for :name:Symbol.
我查阅了文档,我认为我做得对,但我猜不是吗?我究竟做错了什么?
在反应中你可以做类似的事情:
var Wrap = React.createClass({
render: function() {
return <div>{ this.props.children }</div>;
}
});
var App = React.createClass({
render: function() {
return <Wrap><h1>Hello word</h1></Wrap>;
}
});
Run Code Online (Sandbox Code Playgroud)
这允许您将组件传递给另一个组件.但是,如果Wrap有另一个你可以把内容放入的div.请考虑以下事项:
var Wrap = React.createClass({
render: function() {
return (
<div>
<ul className="icons">
// Another compoent should be passed here from App to render icons.
</ul>
{ this.props.children }
</div>
);
}
});
var App = React.createClass({
render: function() {
return <Wrap><h1>Hello word</h1></Wrap>;
}
});
Run Code Online (Sandbox Code Playgroud)
在上面的示例中,您可以看到我不仅要传递App组件的子项,还要传递另一个组件的图标ul.这可能吗?
如果是这样,怎么样?
所以我有这个问题,其中libv8-3.16.14.3无法安装,即使它欺骗性地告诉你它确实安装.
所以问题的第一个迹象就是:
An error occurred while installing libv8 (3.16.14.3), and Bundler cannot continue.
Make sure that `gem install libv8 -v '3.16.14.3'` succeeds before bundling.
Run Code Online (Sandbox Code Playgroud)
期间bundle install.所以我做了一些谷歌搜索,并遇到了这个响应,运行时:
gem install libv8 -v '3.16.14.3' -- --with-system-v8
Building native extensions with: '--with-system-v8'
This could take a while...
Successfully installed libv8-3.16.14.3
Parsing documentation for libv8-3.16.14.3
Done installing documentation for libv8 after 1 seconds
1 gem installed
Run Code Online (Sandbox Code Playgroud)
引导您认为它有效.但bundle install再次运行,看到有问题的错误是:
An error occurred while installing libv8 (3.16.14.3), and Bundler cannot continue. …Run Code Online (Sandbox Code Playgroud) 有趣的是我如何获得内存分配错误gulp,无论是错误的输出:
gulp compile:development
[15:33:51] Warning: gulp version mismatch:
[15:33:51] Global gulp is 3.8.7
[15:33:51] Local gulp is 3.8.6
[15:33:52] Using gulpfile ~/Dropbox/AisisGit/Zen/gulpfile.js
[15:33:52] Starting 'bower'...
[15:33:52] Using cwd: ./
[15:33:52] Using bower dir: ./bower_components
[15:33:52] Starting 'compile:jsx'...
[15:33:52] Starting 'compile:js:development'...
[15:33:52] Starting 'compile:sass:development'...
[15:33:52] Starting 'serve'...
[15:33:52] Finished 'serve' after 1.88 ms
[15:33:52] Server started on 9010 port
[15:33:52] Finished 'compile:jsx' after 376 ms
[15:33:52] Finished 'compile:js:development' after 371 ms
[15:33:52] Starting 'watch:compilejs'...
[15:33:52] Finished 'watch:compilejs' after 6.4 ?s
gulp(97412,0x7fff7ba57300) …Run Code Online (Sandbox Code Playgroud) 我正在为Reactjs构建覆盖机制,并在Reactjs中使用Jquery就像用锤子砸拇指一样。你不做。
所以我在jQuery中有这两个功能非常有用
window.jQuery(DOMNode).offset();
window.jQuery(elem).position();
Run Code Online (Sandbox Code Playgroud)
我到处都在寻找javascript等效项。我什至查看了它们的实现细节,但是可惜我不想正确复制它,因为那和使用它们自己的功能是一样的。
有人知道有什么函数会让我获得这些函数的相同或相似的返回值吗?
我有以下json:
{
"comments":[
{
"id":1,
"comment_text":"asdasdadasdsadsadadsa",
"author":"adsfasdasdsad",
"post_id":1,
"ancestry":null,
"archived":false,
"created_at":"2014-10-16T23:16:44.173Z",
"updated_at":"2014-10-16T23:16:44.173Z",
"is_moderated":false,
"avatar_url":null,
"slug":null,
"blog_id":2,
"children":[
]
},
{
"id":2,
"comment_text":"idlsfghlskdhvbsldfhjdslifds\nzf\ndsf\nds\nf\ns\nf\ns\nfds\nfsdjghfsdligjhsepfiguhefdliguhefldiughfeliughnfesg\nf\nsg\ns\ng\ns\ndf\nsd\nf\nsdgsofughlefidughls;uhgsuhg.vskjfhglsiuhg.sfv",
"author":"asdsdasdad",
"post_id":1,
"ancestry":null,
"archived":false,
"created_at":"2014-10-16T23:17:02.270Z",
"updated_at":"2014-10-16T23:17:02.270Z",
"is_moderated":false,
"avatar_url":null,
"slug":null,
"blog_id":2,
"children":[
{
"id":3,
"comment_text":"fdsfdsfdsfsdfsfsdf",
"author":"sdfdsfdsfdsfds",
"post_id":1,
"ancestry":"2",
"archived":false,
"created_at":"2014-11-28T17:39:47.059Z",
"updated_at":"2014-11-28T17:39:47.059Z",
"is_moderated":false,
"avatar_url":null,
"slug":null,
"blog_id":2,
"children":[
{
"id":4,
"comment_text":"fdsfdsfdsdsfdsfds",
"author":"sdfsdfdsfsdfdsfds",
"post_id":1,
"ancestry":"2/3",
"archived":false,
"created_at":"2014-11-28T17:39:53.049Z",
"updated_at":"2014-11-28T17:39:53.049Z",
"is_moderated":false,
"avatar_url":null,
"slug":null,
"blog_id":2,
"children":[
{
"id":5,
"comment_text":"sdfdsfdsfdsfdssdfsdfdsfdsfdsfds",
"author":"sdfsdfdsfdsfdsf",
"post_id":1,
"ancestry":"2/3/4",
"archived":false,
"created_at":"2014-11-28T17:40:02.032Z",
"updated_at":"2014-11-28T17:40:02.032Z",
"is_moderated":false,
"avatar_url":null,
"slug":null,
"blog_id":2,
"children":[
]
}
]
}
] …Run Code Online (Sandbox Code Playgroud) 我需要找到其中$('.post-content')没有数据属性的所有元素。我试着说类似的话if (!$('.post-content p').attr('data-example')) { ... }
但显然这行不通。那么我将如何执行以下操作:
查找所有属于 .post-content 且没有数据属性的 p 标签并将其删除。
我认为它非常简单,但是所有堆栈问题和文档以及 jquery 和互联网都只有“如何添加、如何查找、如何添加值 - 到数据属性”
所以我不太清楚,我很抱歉。在示例中:
<div class="post-content">
<p data-attribute="foo">
<span data-attribute="boo">
<p>...</p>
</span>
</p>
<p> ... </p>
</div>
Run Code Online (Sandbox Code Playgroud)
我不希望p删除嵌套标签,就像您在此处看到的那样,其中 p 标签下有一个具有数据属性的嵌套 p 标签。p只是没有数据属性的顶级标签。
提供的解决方案倾向于删除嵌套和顶层。
我很困惑为什么我在控制台中收到此错误.我已经阅读了所有的dos,据我所知,我正在做这件事.
在我的页面上,我有一个
<div id="aisis-writer"></div>
Run Code Online (Sandbox Code Playgroud)
我希望我的反应元素绑定在哪里.然后我创建了一个简单的React组件,它什么都不呈现:
var AisisWriter = React.createClass({
getInitialState: function(){},
componentDidMount: function(){},
render: function(){
return null;
}
});
React.render(
<AisisWriter />,
document.getElementById('aisis-writer')
);
Run Code Online (Sandbox Code Playgroud)
非常基本的.当我加载页面时,我看到:Uncaught Error: Invariant Violation: _registerComponent(...): Target container is not a DOM element.所以我想,好吧也许我拼错了一些东西,所以在控制台中我做:
document.getElementById('aisis-writer');
Run Code Online (Sandbox Code Playgroud)
我回来了:
<div id="aisis-writer"></div>
Run Code Online (Sandbox Code Playgroud)
所以我完全错过了什么?为什么我收到此错误?
所以我有一些代码看起来像:
<ul>
<li>
<ul>
<li> ... </li>
</ul>
</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
这已经缩进了。我没有样式来缩进这一点。根据计算的样式,没有 margin-left,但所有内容实际上都是缩进的,我想这是嵌套 ul 元素的默认行为?
comment-children无论如何,在每个嵌套的 ul 上,我都有一个名为I need to say only 5 down can indent (这样就完成了,太棒了)的类,.comment-children .comment-children .comment-children .comment-children .comment-children但在 640px 的宽度下,所有嵌套都必须关闭。
我遇到问题的部分是ul元素默认是嵌套的http://jsfiddle.net/d7az0jv3/
你想让我做什么
comment-children我正在寻找使用Postgres的功能,通过activerecords json处理功能将json设置为一列我想知道如何在表创建类似{name: '', other_name: ''}等等时给它一个默认值...
我也想了解如何为列创建默认的json值,如上面的示例,然后我填写值,但在其他时间将其重置为"默认",如何看起来.