我正在尝试根据用户查看某个网页的时间启用 div 类,例如:博客、索引或 ../page/webpage
代码是这样的:
{% unless template contains "index" and settings.slideshow_enabled %}
<div class="container main content">
{% endunless %}
Run Code Online (Sandbox Code Playgroud)
“容器主要内容”在导航栏后面显示了一个图像。在其他页面上,图像从导航栏下方开始。这里有一个明显的例子:http : //retina-theme.myshopify.com/
我想要相同的主页,链接上面的链接,在选定的页面或模板上:
{% if template == "index" and template == "page" and settings.slideshow_enabled %}
<div class="container main content">
{% endif %}
Run Code Online (Sandbox Code Playgroud)
到目前为止,我没有尝试过任何工作。有小费吗?
编辑:
我还不能回答我自己的问题,但这对 javascript 进行了调整:
{% unless template contains "page" or template contains "index" and settings.slideshow_enabled %}
<div class="container main content">
{% endunless %}
Run Code Online (Sandbox Code Playgroud) 我似乎无法将更新的配置文件保存到数据库.
在我的edit.blade.php中:
{!! Form::model($user, ['method' => 'PATCH', 'route' => ['profile.update', $user->company_name] ]) !!}
// fields
{!! Form::submit('Update Profile', ['class' => 'btn btn-primary']) !!}
{!! Form::close() !!}
Run Code Online (Sandbox Code Playgroud)
在我的ProfilesController中:
public function update($company_name)
{
$user = User::whereCompanyName($company_name)->firstOrFail();
$user->save(); // no validation implemented
flash('You have successfully edited your profile');
return redirect('/');
}
Run Code Online (Sandbox Code Playgroud)
点击更新按钮后,它会在主页上显示flash消息,但它没有保存到数据库中.我来自Rails,我觉得我需要将某些内容列入白名单.
有没有css我可以调整和定位border-left属性?还是"黑客"?下面显示了我想要的内容.黑色矩形代表列和红色,我希望在该列上有边框.可能?
如果没有,我可以在里面添加另一个div然后给div作为border属性吗?
我已经看过关于这个问题的不同问题,似乎没有一个与我的相同:Mac 10.10.2上的新git安装
我使用下面的代码来安装自动完成功能:
curl -OL https://github.com/git/git/blob/master/contrib/completion/git-completion.bash
Run Code Online (Sandbox Code Playgroud)
我也试过以上:-O.
我在.已下载的文件中添加了一个:
mv ~/git-completion.bash ~/.git-completion.bash
Run Code Online (Sandbox Code Playgroud)
然后我编辑我的bash_profile并插入该行以在终端加载时获得自动加载:
if [ -f ~/.git-completion.bash ]; then
source ~/.git-completion.bash
fi
Run Code Online (Sandbox Code Playgroud)
重新启动终端:
Users/user/.git-completion.bash: line 4: syntax error near unexpected token `newline'
Run Code Online (Sandbox Code Playgroud)
下载的文件或我的操作系统是否存在问题?
我现在用Reactjs"试水".基于他们的文档,我掀起了一个我坚持的小项目.到目前为止,当选中复选框时,状态会发生变化,但是......不确定如何更改未选中的状态:
var Foo = React.createClass{(
getInitialState: function() {
return {
location: true,
}
},
onClick: function() {
this.setState({ location: false });
},
render: function() {
var inlineStyles = {
display: this.state.location ? 'block' : 'none'
};
return (
<div>
<input type="checkbox"
onClick={this.onClick}
/> show / hide bar
<hr />
<div style={inlineStyles}>
<p>bar</p>
</div>
</div>
);
}
)};
Run Code Online (Sandbox Code Playgroud)
我是否需要使用一种if statement我想要的东西?我需要this.setState.location: true在未经检查的情况下.
如何使用React创建一个非常非常简单的下拉选择?似乎没什么用.
我有一个数组: var num = [1,2,3,4,5]
功能:
num(e){
this.setState({selected: e.target.value});
}
Run Code Online (Sandbox Code Playgroud)
在渲染中:
<select option="{num}" value={this.state.selected} onChange={this.num} />
Run Code Online (Sandbox Code Playgroud)
没有错误消息,没有任何消息.我通常使用npm插件,但我只需要一些基本的东西.
我正在寻找一种更快,使用更少服务器处理的方法。在我的应用程序中,我可以同时使用.where和.detect:
哪里:
User.where(id: 1)
# User Load (0.5ms)
Run Code Online (Sandbox Code Playgroud)
检测:
User.all.detect{ |u| u.id == 1 }
# User Load (0.7ms). Sometimes increases more than .where
Run Code Online (Sandbox Code Playgroud)
我了解这会.detect 返回列表中该块返回TRUE的第一项,但是.where如果我有成千上万个Users ,它将与之相比如何?
为清楚起见进行了编辑。
.where在此示例中使用,因为我可能不会id单独查询。如果我有一个名为“名称”的表列怎么办?
Foo.first = {id: 1, start:2000-01-01 07:00:00 UTC, end: 2000-01-01 12:00:00 UTC, total_hours_worked: nil}
Run Code Online (Sandbox Code Playgroud)
end这里作为一个例子。
我已经为两者创建Foo了,因为我只需要几小时/分钟。我以前从未使用过 Time 对象,所以请耐心等待。t.timestartend
我需要使用start和获取总小时数和分钟数end:
start = Foo.find(1).start
end = Foo.find(1).end
start + end #=> errors
start.to_i + end.to_i = 1893438000 #=> What's that?
distance_of_time_in_words(start.to_i + end.to_i) #=> "about 60 years" What?
Run Code Online (Sandbox Code Playgroud)
我期待着5:00:00。我知道这5:00:00实际上意味着凌晨 5 点,但上下文会有所不同。
做了一些搜索我就看到了这个。我真的不想在 Rails/Ruby 中为这个“应该在方法中烘焙”使用更多的 gem。
我的问题将找到我真正想要实现的目标的答案(获取本周的工作总小时数):
Foo.pluck(:total_hours_worked).sum(&:to_d) #=> best way?
Run Code Online (Sandbox Code Playgroud)
哪里:total_hours_worked会有一个字符串,只是为了让事情变得不那么复杂。
我似乎无法遵循这个答案,但也许它与我想要实现的目标不同。
我有一个字符串,该字符串有时可能不同,我需要将该字符串转换为定义的方法名称:
action = "get_name"
# The method
def get_name
puts "James"
end
# Calling the method
action # => undefined method `action' for main:Object
Run Code Online (Sandbox Code Playgroud)
action可以是我定义的任何方法,并且名称采用字符串格式。我可以说action.to_method,你明白我的意思了;)
我想我不能说action.to_sym?
我来自React背景,它足以从一个道具设置你的状态,你可以调用setState({...})更新状态,所以,使用vue/vuex,我发现它很难.
简化:
Vuex州
name: "Foo bar"
Vuex行动
addName
我可以改变状态没问题,但我需要绑定一个输入字段,当更改时,状态会更新.将此视为一种更新表单,其中用户详细信息已预先填写,并且可以更改其名称.
<input @change="addName(newName) v-model="newName" />
Run Code Online (Sandbox Code Playgroud)
我可以添加一个watch来监视newName和更新状态,但是,我需要预先用状态填充输入.哈!我可以使用,beforeMount()但我的状态尚未加载.
computed: {
...mapState([
'name'
]),
},
beforeMount() {
// this.newName = this.name
console.log('Mounted') // Shows in console
console.log(this.name) // nothing
}
Run Code Online (Sandbox Code Playgroud)
名字显示在templete中 <pre>{{ name }}</pre>