Ruby on Rails中是否存在检查行(Check row exist or not in Ruby on Rails)
我是Ruby on Rails的新手,我对mysql有基本的了解。 我正在使用MySQL db。 我的问题是 - 如何检查表中是否存在行。 我已经尝试过这段代码,但它不会直接进入
else
块,而不是if
块:@tasks = User.find_by("user_name = ? AND password = ?", params[:user_name], params[:password]) if @tasks redirect_to action: 'index', status: 302 else redirect_to action: 'detail', status: 302 end
I am new to Ruby on Rails and I have basic knowledge of mysql. I am using MySQL db. My question is -- how to check if a row is exists or not in a table. I have tried this code but it's not going straight to the
else
block, not theif
block:@tasks = User.find_by("user_name = ? AND password = ?", params[:user_name], params[:password]) if @tasks redirect_to action: 'index', status: 302 else redirect_to action: 'detail', status: 302 end
原文:https://stackoverflow.com/questions/22928038
最满意答案
您没有安装自述文件中提到的依赖项。 缺少的功能是lightspeed工具箱的一部分。 您不必单独安装依赖项,支持包将收集所有依赖项。
You did not install the dependencies mentioned in the readme. The missing function is part of the lightspeed toolbox. You don't have to install the dependencies individually, the support package collects all dependencies.
相关问答
更多-
听起来svmtrain功能不在您的路径上。 如果 which svmtrain 显示“找不到svmtrain”,然后你应该确保你有生物信息学工具箱(输入ver并查看它是否在列表中)并且它在你的路径中 。 It sounds like the svmtrain function isn't on your path. If which svmtrain displays "svmtrain not found", then you should make sure that you have the bi ...
-
您没有安装自述文件中提到的依赖项。 缺少的功能是lightspeed工具箱的一部分。 您不必单独安装依赖项,支持包将收集所有依赖项。 You did not install the dependencies mentioned in the readme. The missing function is part of the lightspeed toolbox. You don't have to install the dependencies individually, the support pa ...
-
那是因为这个函数是一个.c文件,你需要编译才能与Matlab一起使用,以及这些函数: vectors_nlmeans_single.c image2vectors_single.c vectors_nlmeans_double.c 如果仔细查看NLMF.m文件的注释部分,您将看到: % First Compile c-code!!!!, with : % mex vectors_nlmeans_single.c -v % mex image2vectors_single.c -v % mex ...
-
RDD是Apache Spark对分布式弹性数据集的抽象 要创建RDD您需要一个SparkContext实例,可以将其视为运行Apache Spark的集群的“连接”或“句柄”。 假设 : 您有一个实例化的SparkContext 您希望将输入视为(Double, Double)值的“平坦”序列, 忽略它们当前“拆分”为Seq[Seq[(Double, Double)]]子序列的方式 您可以按如下方式创建RDD: val sc: SparkContext = ??? val output: Seq[Seq[ ...
-
imbinarize使用256 bin图像直方图来计算Otsu的阈值,因此它期望有一个“uint”图像。 从错误中我们可以推断出你的图像是double ,所以把它转换为uint : img = im2uint8(img) 然后在im之上运行imbinarize im_binarized = imbinarize(img,T) 编辑: 另外你的问题可能是你没有安装图像处理工具箱。 您可以在不使用工具箱的情况下对图像进行阈值处理 im_binarized = im > T; % where T is y ...
-
如何用语音识别数据集训练HMM进行语音识别?(How to train HMM with audio senteces dataset for speech recognition?)[2023-08-30]
我是否需要将句子剪成单词或仅使用句子来训练HMM模型? 从理论上讲,你只需要句子和音素。 但是,隔离的单词可能对您的模型有用(它会增加训练数据的大小) 我需要火车的音素数据集吗? 如果是,我是否需要训练它也使用HMM? 如果不是我的程序如何识别HMM预测输入的音素? 您需要音素,否则如果您的模型没有任何孤立音素的示例,那么您的模型将难以找到正确的音素分段。 您应首先在隔离的音素上训练您的HMM状态,然后添加其余数据。 如果你有足够的数据,你的模型可以在没有孤立的音素例子的情况下学习,但我不会打败它。 我必须 ... -
可能是你从错误的目录运行它(即你正在调用MATLAB无法找到的东西,所以问题不在于输入)。 Probably, you are running this from a wrong directory (i.e. you are calling something that MATLAB just can't find, so the problem is not the input).
-
由于Matlab中的积分与q = integral(fun,xmin,xmax) ,请参见此处 ,而不是int : 来自CIC过滤器的状态 。 Since integral in Matlab is used with q = integral(fun,xmin,xmax), see here, not int: States from CIC filter.
-
Undefined function 'xxx' for input arguments of type 'double'通常表示函数xxx不在路径上。 要确认这确实是问题, which convfft在命令行输入which convfft ,因为which应指示Matlab知道文件所在的位置。 如果找不到该文件,请确保它在您的计算机上存在,并将该文件的父文件夹添加到Matlab路径。 Undefined function 'xxx' for input arguments of type 'double' ...
-
未定义函数'num2str'用于类型'double'的输入参数(Undefined function 'num2str' for input arguments of type 'double')[2022-05-22]
每次运行时都清除路径 ,所以MATLAB无法找到任何文件或函数,无论是否内置(包括num2str )。 每次尝试时,它只会看到C:\然后放弃。 尝试这个: route=3; samples=1; pct=100; filename=char(['B2A_Sample_r',num2str(route),'_',num2str(pct),'%_',num2str(1000+samples)]); directory = 'C:\'; fullfilename = fullfile(directory,fil ...