以为我会把这个问题提交给StackOverflow人群,因为我的想法已经用完了.
我收到用户的请求,一旦点击一个按钮,就会生成一个他们想要自动查看的PDF表单,一旦他们关闭PDF,页面就会成为"最终页面",而不是他们点击按钮的页面从.
在带有按钮的前期最后一页中,控制器调用:
return File(finalForm, "application/pdf", Server.HtmlEncode(finalForm));
Run Code Online (Sandbox Code Playgroud)
但是这已经将控制权传递给了客户端,我无法路由到另一个View.
关于如何显示新视图的任何聪明的想法?
我通常perl -de 42用于获取交互式Perl shell.我见过 Devel :: REPL,我看过一些像http://www.xenoterracide.com/2010/07/making-repl-usable.html这样的博客, 解释了如何Devel::REPL使用插件进行增强,但我还没有使用过.
将调试器用作交互式shell是否太糟糕了?为什么?
注意:此PerlMonks节点中提到的缺点是用户的限制,而不是Perl调试器的限制.
我在哪里可以阅读有关Perl REPL的更多信息?
Devel :: REPL是否准备好迎接风头?
更新: 我接受了Pedro的答案,因为它回答了我问的问题,但我仍然想知道何时以及为什么(如果有的话)使用Perl调试器作为交互式shell与其中一个Perl相比是一个坏主意REPL实现.您更喜欢哪种Perl REPL?
我希望能够定义一个接口的函数,但可以使用提供相同功能的委托或函数来实现.例如,在C++中,我可以编写如下内容:
typedef std::function<int (float)> toInt;
void fun(toInt dg) { ... }
struct impl1 {
int operator()(float x) { ... }
};
int impl2(float x) { ... }
Run Code Online (Sandbox Code Playgroud)
然后使用任一实现调用它:
fun(impl1());
fun(&impl2);
Run Code Online (Sandbox Code Playgroud)
(这个float-> int转换只是一个简单的例子来说明原理,而不是我的实际功能).
我想在D中实现类似的东西.我天真的尝试是这样的:
interface toInt {
int opCall(float);
}
void fun(toInt dg) { ... }
int impl2(float x) { ... }
fun(impl2);
Run Code Online (Sandbox Code Playgroud)
编译器在最后一行抱怨它不能隐式地将impl2转换为toInt类型.我可能只是添加一个重载的实现的乐趣并使转换显式,但我想知道是否有更优雅和一般的方式这样做,如上面的C++示例.
我正在为create控制器的方法编写规范:
describe "POST create" do
it "should create an adtag with valid params" do
campaign = Campaign.make
campaign_attributes = Hash.new
campaign_attributes[:adtag_attributes] = Hash.new
campaign_attributes[:adtag_attributes][:code] = "<h1>Sample code</h1>"
post 'create', { :id => campaign.id, :campaign => campaign_attributes }
end
end
Run Code Online (Sandbox Code Playgroud)
但是当我运行它时,我"Symbol as array index"在控制器中遇到错误,当它试图处理这段代码时:
params[:campaign][:adtag_attributes].each_with_index do |attributes,index|
# some code
end
Run Code Online (Sandbox Code Playgroud)
任何的想法 ?谢谢
编辑1:
我没有编写控制器,但它适用于手动测试.调用我的控制器的视图具有以下代码:
fields_for 'campaign[adtag_attributes][]', adtag do |adtag_form|
Run Code Online (Sandbox Code Playgroud)
也许我的规格不好?
编辑2:
由于Rishav的回答,问题解决了.我不明白在视图中,campaign[adtag_attributes][]意味着campaign[adtag_attributes]是一个数组.
所以我只是换了
campaign_attributes = Hash.new
campaign_attributes[:adtag_attributes] = Hash.new
campaign_attributes[:adtag_attributes][:code] = "<h1>Sample …Run Code Online (Sandbox Code Playgroud) 我刚刚下载了Ruby 1.9.2,我希望它能完全取代我已安装的旧版Ruby(1.8.7).(主要是因为我在安装不同版本的东西时会感到困惑.)
最好的方法是什么?我是否要卸载旧版本?(如果是这样,怎么样?)我可以用新的ruby1.9.2/bin/{ruby,irb}替换旧的ruby1.8.7/bin/{ruby,irb}吗?
我在Windows 7机器上.
class MyClass
{
public:
~MyClass() {}
MyClass():x(0), y(0){} //default constructor
MyClass(int X, int Y):x(X), y(Y){} //user-defined constructor
MyClass(const MyClass& tempObj):x(tempObj.x), y(tempObj.y){} //copy constructor
private:
int x; int y;
};
int main()
{
MyClass MyObj(MyClass(1, 2)); //user-defined constructor was called.
MyClass MyObj2(MyObj); //copy constructor was called.
}
Run Code Online (Sandbox Code Playgroud)
在第一种情况下,当MyClass(1, 2)调用用户定义的构造函数并返回一个对象时,我希望MyObj调用复制构造函数.为什么它不需要为第二个实例调用复制构造函数MyClass?
有没有办法在Java/Tomcat/JSP Web项目中附加到asp.net的"Application_Start"和"Begin_Request"等事件?我真的不想使用JSF或额外的框架(Spring,Struts).我不希望在每页的基础上使用"jspInit"这样的东西,全局事件处理程序是目标.
如果我陷入.net的做事方式,关键是要有一个初始化IoC容器(Application_Start)的中心位置,并实现'每个请求一个数据库事务'工作流程(Begin_Request).
谢谢.
我知道在Ruby 1.9中你可以轻松地重新编码这样的字符串.
s = s.encode('UTF-8')
Run Code Online (Sandbox Code Playgroud)
Ruby 1.8中的等价物是什么?什么需要线路它需要.
我看到的所有教程都是不必要的复杂,我不明白发生了什么.
我正在尝试调整我的MySQL服务器以满足我的需求......我有一个基本问题:什么是密钥缓冲区?
通过尝试和错误,我发现更大的密钥缓冲区使我的插入更快......但我不太明白它是什么.所以...在我做出一些我可能后悔的事情之前,我想知道它是什么,以及它是如何工作的.
我正在运行的脚本(MyISAM表)每秒大约进行2000次插入.
(我的服务器设置是Intel i7,8GB RAM,CentOS 5.5,MySQL Server 5.0.)