可能重复:
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)
我正在尝试创建一个按钮(或复选框),用户可以切换以查看以纯文本格式编写的密码.
这基本上适用于便携式设备,其中输入密码是一种痛苦,并且在写入时以纯文本形式查看它是用户体验改进.
在上面的示例中,更改输入的类型不起作用.
有关如何解决这个问题的任何建议?
我正在尝试将现有数据从MySQL数据库导出到我可以运行的ruby命令中rake db:seed.
这是我的代码.
# Generate db:seed data for proveedores.
$proveedores = R::findAll('tbproveedores');
$proveedoresE = R::exportAll($proveedores);
foreach ($proveedoresE as &$p) {
$line = 'BookSupplier.create(company: "%s", city: "%s", country: "%s", address: "%s", telephone: "%s", contact: "%s", email: "%s", website: "%s"\n';
$exportedLine = sprintf($line, $p['empresa'], $p['ciudad'], $p['pais'], $p['direccion'], $p['telefono'], $p['personacontacto'], $p['email'], $p['website']);
var_dump($exportedLine);
fwrite($seeds, $exportedLine);
echo "<br />";
}
Run Code Online (Sandbox Code Playgroud)
注意\n$ line变量末尾的换行符号.我在网上看到这就是使用新行所需要的全部内容.
我上面代码的输出是(vertabim,一条长行):
BookSupplier.create(company: "Pearson", city: "Lima", country: "Peru", address: "Av. Limon", telephone: "4673535421", contact: "Javier", email: "", …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?
我正在尝试使用Capistrano 3来部署Rails 4应用程序.
#config valid only for Capistrano 3.1
lock '3.1.0'
set :application, 'testapp'
set :scm, :git
set :repo_url, 'git@bitbucket.org:sergiotapia/testapp.git'
set :user, "deploy" # The user on the VPS server.
set :password, "hunter2$$"
set :use_sudo, false
set :deploy_to, "/home/deploy/www/testapp"
set :deploy_via, :remote_cache
set :pty, true
set :format, :pretty
set :keep_releases, 1
set :rails_env, "production"
set :migrate_target, :latest
namespace :deploy do
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
# Your restart mechanism here, for example: …Run Code Online (Sandbox Code Playgroud) 我正在尝试确定是否在我的Web应用程序上显示Spanish或English按钮.
<% if I18n.locale == 'es' %>
<a href="<%= set_english_path %>" class="thin">English</a>
<% else %>
<a href="<%= set_spanish_path %>" class="thin">Spanish</a>
<% end %>
Run Code Online (Sandbox Code Playgroud)
该if条件总是失败,西班牙按钮总是显示.
RubyMine在检查时(调试期间)显示:

那么为什么比较失败呢?
ruby symbols ruby-on-rails internationalization ruby-on-rails-3
我正在尝试使用Capistrano将我的应用程序部署到我的DigitalOcean服务器上.
这不是我第一次在DigitalOcean上配置RoR服务器而Capistrano部署了这就是为什么我感到困惑; 我的工作流程没有改变任何内容.
这是我的Capistrano配置文件:
require 'bundler/capistrano'
require 'rvm/capistrano'
set :application, "foobar"
set :repository, "git@bitbucket.org:sergiotapia/foobar.git"
set :ping_url, "http://192.168.1.1/"
set :scm, :git
set :scm_verbose, true
default_run_options[:pty] = true
set :user, "sergiotapia" # The user on the VPS server.
set :password, "hunter2"
set :use_sudo, false
set :deploy_to, "/home/sergiotapia/www/#{application}"
set :deploy_via, :remote_cache
set :keep_releases, 1
set :rails_env, "production"
set :migrate_target, :latest
role :web, "192.168.1.1"
role :app, "192.168.1.1"
namespace :deploy do
task :start do ; end
task :stop do ; end
task :restart, roles: :app, …Run Code Online (Sandbox Code Playgroud) class UserPreview < ActionMailer::Preview
# Accessible from http://localhost:3000/rails/mailers/notifier/welcome_email
def welcome_email
UserMailer.welcome_email(User.first)
end
end
Run Code Online (Sandbox Code Playgroud)
我使用Ruby on Rails 4.1进行了这个简单的邮件预览.
如果我注释掉了我routes.rb文件中的所有路由而只留下这个,那么邮件程序预览就会起作用:
MyTestApp::Application.routes.draw do
end
Run Code Online (Sandbox Code Playgroud)
所以显然我的一个权利是在默认的Rails之前用于邮件预览.
我需要输入路由rb文件?
可能重复:
是否可以基于子域创建ASP.NET MVC路由?
我打算建立一个网站,允许用户创建自己的虚拟商店,由我的网站托管.
想想eBay; 让小企业创建他们的商店.
例如:
www.foo.com - The main website.
www.georgestires.foo.com - "George's Tires" online store.
Run Code Online (Sandbox Code Playgroud)
我会让用户在一定程度上创建自己的样式表和自定义,但这是为了以后.现在我想知道如何在MVC 3网站上实现这个功能.
我确实在这里没有腿站在零点.任何和所有的建议表示赞赏.我知道在IIS中我可以创建一个"bar.foo.com"子域绑定并直接流向我的ASP.Net MVC3应用程序,但这是否意味着每次有人创建他们的商店时我都必须以编程方式创建一个新的捆绑?
这甚至可能吗?我应该看看这种方法吗?
我该怎么换回来?
我安装了RVM,然后安装了Ruby 1.9.3,然后运行gem install rails.
运行rails -v我可以看到我有Rails 4.0.0.rc1,我不想使用该版本,因为我的托管服务提供商不支持.
如何安装Rails 3.2.13并在运行rails new命令时将其用作默认值?
我正在使用Go内置的http服务器并轻拍以响应某些网址:
mux.Get("/products", http.HandlerFunc(index))
func index(w http.ResponseWriter, r *http.Request) {
// Do something.
}
Run Code Online (Sandbox Code Playgroud)
我需要将一个额外的参数传递给这个处理函数 - 一个接口.
func (api Api) Attach(resourceManager interface{}, route string) {
// Apply typical REST actions to Mux.
// ie: Product - to /products
mux.Get(route, http.HandlerFunc(index(resourceManager)))
// ie: Product ID: 1 - to /products/1
mux.Get(route+"/:id", http.HandlerFunc(show(resourceManager)))
}
func index(w http.ResponseWriter, r *http.Request, resourceManager interface{}) {
managerType := string(reflect.TypeOf(resourceManager).String())
w.Write([]byte(fmt.Sprintf("%v", managerType)))
}
func show(w http.ResponseWriter, r *http.Request, resourceManager interface{}) {
managerType := string(reflect.TypeOf(resourceManager).String())
w.Write([]byte(fmt.Sprintf("%v", managerType)))
} …Run Code Online (Sandbox Code Playgroud)