首页
\
问答
\
在Rails中从ActiveRecord :: RecordNotFound救援(rescue from ActiveRecord::RecordNotFound in Rails)
在Rails中从ActiveRecord :: RecordNotFound救援(rescue from ActiveRecord::RecordNotFound in Rails)
用户只能编辑自己的帖子,所以我使用以下内容来检查用户是否可以输入编辑表单:
def edit @post = Load.find(:first, :conditions => { :user_id => session[:user_id], :id => params[:id]}) rescue ActiveRecord::RecordNotFound flash[:notice] = "Wrong post it" redirect_to :action => 'index' end
但它不工作,任何想法我做错了什么?
A user can only edit its own post, so I use the following to check if a user can enter the edit form:
def edit @post = Load.find(:first, :conditions => { :user_id => session[:user_id], :id => params[:id]}) rescue ActiveRecord::RecordNotFound flash[:notice] = "Wrong post it" redirect_to :action => 'index' end
But it is not working, any ideas what I am doing wrong?
原文:https://stackoverflow.com/questions/2336593
更新时间:2023-11-22 20:11
最新回答
一般,你保存pom文件的修改(比较新的ide直接自动刷新,后面都不需要操作了),项目刷新一下,就会实现pom的配置的更新,如下: ---点击工程(右键)----选择刷新(refresh)----就会自动下载相应的jar包(这种情况一定要联网)或者直接加载进去本地库中的jar包。
安装 Maven 之前要求先确定你的 JDK 已经安装配置完成。Maven是 Apache 下的一个项目,目前最新版本是 3.1.0,我用的也是这个。 首先去官网下载 Maven 下载完成之后将其解压,我将解压后的文件夹重命名成 maven,并将它放在 D:\Server 目录下,...
相关问答
更多-
maven3运行时可以执行maven2兼容的pom.xml文件(Can maven3 runtime execute maven2 compatible pom.xml files)[2022-09-27]
maven 3主要与maven 2配置兼容。 但仍然存在一些不兼容性。 要查看完整列表,您应该在这里查看插件有时会出现问题(正如Torsten建议的那样)。 资源: Maven 3.x插件兼容性矩阵 在同一主题上: 切换到maven3 maven 3 is mostly compatible with maven 2 configuration. But there is still some incompatibilities. For a full list you should check here ... -
Maven命令来确定Maven正在使用哪个settings.xml文件(Maven command to determine which settings.xml file Maven is using)[2023-01-28]
用-X选项(debug)启动maven并检查输出的开头。 应该有这样的东西: ... [INFO] Error stacktraces are turned on. [DEBUG] Reading global settings from c:\....\apache-maven-3.0.3\conf\settings.xml [DEBUG] Reading user settings from c:\....\.m2\settings.xml [DEBUG] Using local repository ... -
我强烈反对修改mvn.cmd 。 即使你弄清楚如何在命令行和InteliJ中做到这一点,那么考虑转移到某种持续集成框架,例如Jenkins,它将使用默认的mvn.cmd ? 如果没有可能用现有的Maven工具实现你想要的东西,我建议编写自己的Maven插件,(参见本教程 ),并在那里放置所需的功能。 它将保证这一特定代码段将在所有环境中执行,这是确保每次都启动命令的方法。 I would strongly discourage modification of mvn.cmd. Even if you fig ...
-
配置中存在拼写错误(可能是settings.xml或POM文件): http://:/artifactory/不是有效的URL,请尝试使用http://artifactory/ 。 编辑如果URL在浏览器中有效,则Maven无权访问。 错误消息说明:Maven尝试下载文件,服务器响应HTTP状态403(禁止) 。 由于它适用于Web浏览器,因此这绝对是Artifactory服务器上的settings.xml和权限的问题。 我曾经遇到过与Nexus类似的问题; 它被配置为拒绝访问某些包。 检查存储库服务器的日 ...
-
节点应该是suiteXmlFiles / suiteXmlFile而不是suiteXMLFiles / suiteXMLFile : https : suiteXMLFile
org.apache.maven.plugins maven-surefire-plugin < ... -
我认为您正在寻找的是基于配置文件的属性,如下所示:
jira user password -
我会写你自己的插件。 从命令行开始: mvn archetype:generate -DgroupId=mygroup -DartifactId=myartifact 从列表中选择maven插件。 将生成一个插件项目。 插件代码将有一个execute()方法,只需实现它。 实现这个简单的方法比使用Ant插件破解要快得多,也更简洁。 例如,使用普通的进程exec语义,您可以运行两个目录树的递归diff。 无论你从命令行做什么。 但如果它很简单,只需运行一个命令行,请先查看http://mojo.codeha ...
-
这是两个不同的问题: 我很奇怪maven知道哪个archetype用于指定的pom.xml 原型插件通常以交互方式使用。 您只需调用mvn archetype:create ,向导将引导您完成不同的步骤。 您无需在pom中配置任何内容。 事实上,将原型信息放在现有项目中是愚蠢的,因为原型用于创建新项目。 我没有发现maven-archetype-quickstart的pom.xml和maven-archetype-webapp的pom.xml之间没有任何区别。 主要区别在于webapp包含一个文件夹src ...
-
versions-maven-plugin无法读取maven-metadata.xml(versions-maven-plugin is not able to read maven-metadata.xml)[2024-03-06]
朋友们, 似乎Apache中央存储库已经解决了这个问题。 因此,如果不进行任何代码更改,问题现在就解决了。 Friends, It seems like Apache central repository has fixed the issue. So without making any code change, the problem is fixed now. -
Properties Maven插件可能符合您的目标。 属性:read-project-properties将读取属性文件并将它们存储为项目属性,如下例所示: -
org.codehaus.mojo properties-maven-plugin 1.0-al ...