这是我尝试过的,而且simple_form_for调用忽略了我的课堂设置.
# Rails code in view:
<%= simple_form_for @admin_artist, :class => 'foobarbaz' do |f| %>
# Renders:
<form accept-charset="UTF-8" action="/admin/artists" class="simple_form new_admin_artist" id="new_admin_artist" method="post" novalidate="novalidate">
Run Code Online (Sandbox Code Playgroud)
有什么建议?
我正在使用Firefox和Firebug Developer工具.
View Source(Ctrl + U)中显示的HTML是否与使用Firebug检查元素时看到的HTML不同?
两者有什么不同?
这是我正在尝试做的事情:
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult Index(ContactModel model)
{
if (ModelState.IsValid)
{
// Send email using Model information.
return RedirectToAction("Gracias", model);
}
return View(model);
}
public ActionResult Gracias(ContactModel model)
{
return View(model);
}
Run Code Online (Sandbox Code Playgroud)
所有三种操作方法都在同一个控制器中.基本上,用户在联系表单中键入一些数据,我想使用他们在Model对象中的名称将它们重定向到感谢页面.
代码是,它可以工作,但URL与GET变量一起传递.不理想.
http://localhost:7807/Contacto/Gracias?Nombre=Sergio&Apellidos=Tapia&Correo=opiasdf&Telefono=oinqwef&Direccion=oinqef&Pais=oinqwef&Mensaje=oinqwef
Run Code Online (Sandbox Code Playgroud)
有什么建议?
我想验证用户是否登录到服务器的每个请求.
就像是:
:before_filter verify_logged_in
Run Code Online (Sandbox Code Playgroud)
我应该在哪里放置before_filter,以便它适用于所有控制器操作和所有请求?
在一个简单的ASP.Net MVC4测试应用程序中,我安装了无点NuGet包并遵循本教程.
我的.less文件被正确解析为CSS,并在以后正常工作debug=true.
<link href="/Public/less/main.less" rel="stylesheet"/>
<link href="/Public/less/home.less" rel="stylesheet"/>
<link href="/Public/less/a.less" rel="stylesheet"/>
<link href="/Public/less/b.less" rel="stylesheet"/>
<link href="/Public/less/c.less" rel="stylesheet"/>
Run Code Online (Sandbox Code Playgroud)
但是当我debug=false为了让它缩小并组合成单个样式表而设置时,我得到了这个:
<link href="/Public/less?v=" rel="stylesheet"/> // NOT WORKING!
Run Code Online (Sandbox Code Playgroud)
这是我的捆绑配置文件; 再次,直接从教程:
public class BundleConfig
{
// For more information on Bundling, visit http://go.microsoft.com/fwlink/?LinkId=254725
public static void RegisterBundles(BundleCollection bundles)
{
// Compile .less files and create a bundle for them.
var lessBundle = new Bundle("~/Public/less").Include(
"~/Public/less/main.less",
"~/Public/less/home.less",
"~/Public/less/a.less",
"~/Public/less/b.less",
"~/Public/less/c.less");
lessBundle.Transforms.Add(new LessTransform());
lessBundle.Transforms.Add(new CssMinify());
bundles.Add(lessBundle);
}
} …Run Code Online (Sandbox Code Playgroud) folder_to_analyze = ARGV.first
folder_path = File.join(Dir.pwd, folder_to_analyze)
unless File.directory?(folder_path)
puts "Error: #{folder_path} no es un folder valido."
exit
end
def get_csv_file_paths(path)
files = []
Dir.glob(path + '/**/*.csv').each do |f|
files << f
end
return files
end
def get_xlsx_file_path(path)
files = []
Dir.glob(path + '/**/*.xls').each do |f|
files << f
end
return files
end
files_to_process = []
files_to_process << get_csv_file_paths(folder_path)
files_to_process << get_xlsx_file_path(folder_path)
puts files_to_process[1].length # Not what I want, I want:
# puts files_to_process.length
Run Code Online (Sandbox Code Playgroud)
我正在尝试在Ruby中创建一个简单的脚本,允许我从命令行调用它,就像ruby counter.rb mailing_list1它进入文件夹并计算所有.csv和.xls文件.
我打算对每个文件进行操作,获取行数等. …
我正在使用Filepicker.io来处理我网站上的图片上传.
我也使用FancyBox来显示一个漂亮的滑块.:如果我使用一个普通图像一样,一切工作正常http://i.imgur.com/asdf.jpeg的<img src="">.意思是我单击图像并正确弹出滑块.
但是,当我切换出那些静态图像网址并使用我的Filepicker地址时,当我点击图像打开fancybox时,图像就会被下载.
以下是我在Google Chrome上的控制台中收到的消息:
资源解释为Document但使用MIME类型image/jpeg传输:"https://www.filepicker.io/api/file/yknn4hWSOOm2NLZYGR3O?dl=false".
有什么建议?
我需要使用正则表达式验证一些输入.
以下是一些示例用例和预期结果.
0001 - Matched
001 - Matched
01 - Matched
00.12312 - Matched
000.1232 - Matched
1 - Not matched
20 - Not matched
0.1 - Not matched
0.123123 - Not matched
Run Code Online (Sandbox Code Playgroud)
像这样的正则表达式会是什么样的?如果第一个char是0第二个char,numerical[0-9]则它无效.
我试过这个,但它不起作用.
[0][0-9]
Run Code Online (Sandbox Code Playgroud) 可能重复:
JQuery更改输入字段的类型
在这里演示:
http://jsbin.com/welcome/73795/edit
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<input type="password" name="password" />
<button>Show Password</button>
$(document).ready(function() {
$('button').click(function() {
$('input').attr('type', 'text');
});
});
Run Code Online (Sandbox Code Playgroud)
我正在尝试创建一个按钮(或复选框),用户可以切换以查看以纯文本格式编写的密码.
这基本上适用于便携式设备,其中输入密码是一种痛苦,并且在写入时以纯文本形式查看它是用户体验改进.
在上面的示例中,更改输入的类型不起作用.
有关如何解决这个问题的任何建议?
date我的数据库中有一个类型字段.
这是我正在使用的视图代码:
# Using 'as: :string' to avoid those three dropdowns rails generates.
= f.input_field :start_date, as: :string, class: 'form-control datepicker'
Run Code Online (Sandbox Code Playgroud)
保存日期时,我使用一个显示日历的jquery插件,并写入如下日期:11/05/2013.
但是,在编辑同一记录时,输入会填充一个值2013-05-11.
我怎样才能使它如此simple_form实际上尊重我定义的日期格式en.yml?