我有一个字符串:"31-02-2010"并想检查它是否是一个有效的日期.最好的方法是什么?
我需要一个方法,如果字符串是有效日期,则返回true,否则返回false.
我有一张桌子projects.
id title created_at claim_window
1 Project One 2012-05-08 13:50:09.924437 5
2 Project Two 2012-06-01 13:50:09.924437 10
Run Code Online (Sandbox Code Playgroud)
A)我想通过计算找到截止日期deadline = created_at + claim_window(No. of days).
跟随之类的事情.
id title created_at claim_window deadline
1 Project One 2012-05-08 13:50:09.924437 5 2012-05-13 13:50:09.924437
2 Project Two 2012-06-01 13:50:09.924437 10 2012-06-11 13:50:09.924437
Run Code Online (Sandbox Code Playgroud)
B]我也想找到截止日期已经过去的项目
id title created_at claim_window deadline
1 Project One 2012-05-08 13:50:09.924437 5 2012-05-13 13:50:09.924437
Run Code Online (Sandbox Code Playgroud)
我尝试下面的事情.
SELECT * FROM "projects" WHERE (DATE_PART('day', now()- created_at) >= (claim_window+1))
Run Code Online (Sandbox Code Playgroud)
但由于某种原因它不起作用.
我想使用JavaScript禁用浏览器刷新.
目前,我正在使用window.onbeforeunload,我不希望在用户刷新浏览器时调用它.
最好的方法是什么?
a = b = c = d = 5
puts (a) >> 5
puts (b) >> 5
puts (b) >> 5
puts (b) >> 5
a= a+1
puts (a) >> 6
puts (b) >> 5
Run Code Online (Sandbox Code Playgroud)
我发现分配这样的值没有问题.我的问题是,应该像上面给出的那样分配还是像这样?
a , b, c, d = 5, 5, 5, 5
Run Code Online (Sandbox Code Playgroud) database.yml中使用最广泛的选项如下:
adapter
encoding
database
pool
username
password
socket
host
port
timeout
Run Code Online (Sandbox Code Playgroud)
我知道使用上面的大部分但是池.所以我想知道database.yml中pool选项的用途是什么,或者我们需要为具有非常繁忙流量的应用程序设置任何其他参数.
attr_accessible(*attributes)和attr_protected(*attributes)?有什么区别?例子很好.
我看到很多开发人员在他们的模型中使用它们 我搜索了差异,但我不确切地知道它们是什么.在不同情况下,重要性及其必要性是什么?
当我在postgresql上的Rails应用程序中运行我的迁移时,我得到了以下通知
NOTICE: CREATE TABLE will create implicit sequence "notification_settings_id_seq" for serial column "notification_settings.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "notification_settings_pkey" for table "notification_settings"
Run Code Online (Sandbox Code Playgroud)
我的迁移文件包含088_create_notification_settings.rb
class CreateNotificationSettings < ActiveRecord::Migration
def self.up
create_table :notification_settings do |t|
t.integer :user_id
t.integer :notification_id
t.boolean :notification_on
t.boolean :outbound
end
end
def self.down
drop_table :notification_settings
end
end
Run Code Online (Sandbox Code Playgroud)
我想知道
这个通知意味着什么?
如何避免这种通知?
如果不避免,此类通知对应用程序的影响是什么?
问候,
萨里尔
说我有这个简短的代码:
item = Item.find(params[:id])
render :json => item.to_json
Run Code Online (Sandbox Code Playgroud)
但我需要插入/推送额外的信息到返回的json对象,我该怎么做?
让我们说我需要插入这个额外的信息:
message : "it works"
Run Code Online (Sandbox Code Playgroud)
谢谢.
我有问题,当我试图通过点击提交按钮提交表单时,如果我再次点击提交按钮,它将需要一些时间来发布请求它将再次发送所有参数和参数保存两次,三次......等等.
我不知道如何限制提交按钮,以便表单不应该提交两次.我想当我提交时,我必须禁用提交按钮,以便用户无法再次点击它,这是正确的方法吗?
我想找到表格艺术家的数据,其中名称以字母a,b,c开头.
i.e.
My o/p should contain
Adam
Alan
Bob
Ben
Chris
Cameron
But not GlAin, doC, dolBie
Run Code Online (Sandbox Code Playgroud) ruby ×4
javascript ×2
mysql ×2
postgresql ×2
activerecord ×1
date ×1
datetime ×1
forms ×1
html ×1
json ×1
string ×1