我正在使用devise并尝试下一个:
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :is_worker
def is_worker
if user_signed_in?
@email = current_user.email
if @email && Worker.find_by_email(@email).nil?
redirect_to '/tasksadmins'
else
redirect_to '/workers'
end
else
redirect_to '/users/sign_in'
end
end
end
Run Code Online (Sandbox Code Playgroud)
当我尝试进入网站时:localhost:3000/tasksadmins我得到了:
Oops! It was not possible to show this website
The website at http://localhost:3000/tasksadmins seems to be unavailable. The precise error was:
Too many redirects
It could be temporarily switched off or moved to a new address. Don't forget to check that your internet connection …Run Code Online (Sandbox Code Playgroud) 我知道我可以传递矩阵的所有元素并做到这一点.
但也许还有另一种选择.
我想要做:
mat1 = mat2 * mat1;
Run Code Online (Sandbox Code Playgroud)
mat1中的每个元素变为负数或大于255,我想留下前一个元素.
例如(结果不正确,这仅用于示例):
mat1 = [10 25 12
33 7 163
232 13 77]
mat2 = [-1 2 -3
4 -5 6
-7 -8 9]
Run Code Online (Sandbox Code Playgroud)
asume mat1 = mat2*mat1给出:
mat1 = [-77.32 59 298
0 -33 12
-600 256 80]
Run Code Online (Sandbox Code Playgroud)
所以我想修复mat1为:
mat1 = [10 59 12
0 7 12
232 13 80]
Run Code Online (Sandbox Code Playgroud) 如何将day_of_month,month和year作为整数输入参数?
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
Calendar start_date = Calendar.getInstance();
System.out.println(dateFormat.format(start_date.getTime()));
int day = start_date.get(Calendar.DAY_OF_MONTH);
int month = start_date.get(Calendar.MONTH);
int year = start_date.get(Calendar.YEAR);
String result = day + "/" + month + "/" + year;
Run Code Online (Sandbox Code Playgroud)
但是,今天的日期是:2012年12月1日,而结果是:01/11/12.
我需要按名称对查询结果进行分组,并显示每个名称的结果数量.
控制器:
def show
@task = Task.where(:name => params[:name])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @task }
end
end
Run Code Online (Sandbox Code Playgroud)
我需要定义输出如下内容的东西:
show.html.erb:
Name | # of Tasks
Alan | 2
Bob | 1
Run Code Online (Sandbox Code Playgroud)
我怎么能做到这一点?谢谢.
我成功找到了登录用户的ID,方法是:
#{session['warden.user.user.key'][1][0]}
Run Code Online (Sandbox Code Playgroud)
如何获取用户使用该电子邮件登录的电子邮件?
我跑:
params[:taxes].each { |pst|
puts(pst)
}
Run Code Online (Sandbox Code Playgroud)
得到了:
{"country"=>"USA", "tax"=>"20"}
Run Code Online (Sandbox Code Playgroud)
我怎样才能得到这个国家的参数?
我试过了:
pst[:country]
pst["country"]
Run Code Online (Sandbox Code Playgroud)
但它不会打印任何东西.
任何帮助赞赏!
我有下一堂课:
class A {
};
class B : public A {
int num;
};
Run Code Online (Sandbox Code Playgroud)
在我的主要我有:
int main() {
A* vec; // A is a class with pure virtual functions
vec = new B[2]; // want to create a vector of B
}
Run Code Online (Sandbox Code Playgroud)
正确定义了vec [0],但vec [1]为NULL.为什么不给我一个合适的记忆?
我不想改变主线.只是让它工作.
(我知道我可以把主要改成:B*vec = new B [2]但我不想要)
任何帮助赞赏!
我有下一个元素:
<li>
"abcd"
<div>something here</div>
<div>and here</div>
</li>
Run Code Online (Sandbox Code Playgroud)
没有包装文本:abcd在span中,有一个选项用css加粗它?
我只想加粗这个文本,而不是文本something here或and here.
font-weight:bold;
Run Code Online (Sandbox Code Playgroud)
任何帮助赞赏!
我想通过点击它来改变div的高度.
为什么它在第一次点击时不起作用而第二次点击不起作用?
我不知道为什么,但div的高度是""(在第二次点击是20px因为else condition)
如果我在html元素中定义div的高度(style ="height:20px"),它就可以了.
<html>
<head>
<script>
function divOpen() {
var divHeight= document.getElementById("divBottom").style.height;
if (divHeight=="20px") {
document.getElementById("divBottom").style.height="200px";
}
else {
document.getElementById("divBottom").style.height="20px";
}
}
</script>
<style>
div{
border:solid 1px gray;
width:200px;
height:20px;
}
.divBottom {
position: fixed;
bottom: 0;
right: 20px;
cursor: pointer;
}
</style>
</head>
<body>
<div class="divBottom" id="divBottom" onclick="divOpen()"></div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
所以我知道如何解决它,但我不知道为什么第一次点击时高度为空.
请告诉我..
任何帮助赞赏!
我想打印以下属性isChecked:
<!DOCTYPE html>
<html>
<head>
<script>
function myFunction(){
alert(document.getElementById('myId').isChecked);
}
</script>
</head>
<body>
<img id="myId" isChecked="0"/>
<br>
<button onclick="myFunction();">Click me</button>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
它打印我 undefined
任何帮助赞赏!