我有通常的Jquery datepicker正常工作.但我想将它提供给一组选择框而不是一个文本字段.我已成功将其输入到具有特定格式的一个选择字段中,但我不确定如何将所有三个字段输入到具有不同格式的不同字段中.
$(document).ready(function(){
$("#search_startdate").datepicker({showOn: 'button',
buttonImage: '/images/cal/calendar.gif',
buttonImageOnly: true,
minDate: 0,
maxDate: '+6M +10D',
showAnim: 'fadeIn',
altField: '#startdate_month',
altFormat: 'MM',
altField: '#startdate_day',
altFormat: 'dd'});
//$("#datepicker").datepicker({showOn: 'button', buttonImage: 'images/calendar.gif', buttonImageOnly: true});
});
Run Code Online (Sandbox Code Playgroud)
这不起作用,它适用于最后一个字段,但忽略第一个字段.如果我删除第二组altField和altFormat行,第一组就可以了.
我也试过把它们放在一个系列中,
altField: '#startdate_month', '#start_day', altFormat: 'MM', 'dd'
Run Code Online (Sandbox Code Playgroud)
问题与此处相同:
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Jquery/Q_24767646.html
有任何想法吗?
谢谢,
jquery jquery-ui ruby-on-rails datepicker jquery-ui-datepicker
我正在寻找在rails中甚至可能的示例中进行协同过滤的解决方案.到目前为止,我只发现了acts_as_recommendable看起来很有用,但我注意到它在过去的两年里没有任何更新.
有谁知道任何其他解决方案和/或示例?
ruby rubygems recommendation-engine ruby-on-rails collaborative-filtering
我的Postgres数据库中有一个Varchar类型的列我想要整数...现在我想要更改它们,不幸的是这似乎不能使用我的rails迁移.
change_column :table1, :columnB, :integer
Run Code Online (Sandbox Code Playgroud)
这似乎输出这个SQL:
ALTER TABLE table1 ALTER COLUMN columnB TYPE integer
Run Code Online (Sandbox Code Playgroud)
所以我尝试这样做:
execute 'ALTER TABLE table1 ALTER COLUMN columnB TYPE integer USING CAST(columnB AS INTEGER)'
Run Code Online (Sandbox Code Playgroud)
但是在这个实例中,强制转换不起作用,因为某些列为空...
有任何想法吗?
错误:
PGError: ERROR: invalid input syntax for integer: ""
: ALTER TABLE table1 ALTER COLUMN columnB TYPE integer USING CAST(columnB AS INTEGER)
Run Code Online (Sandbox Code Playgroud)
Postgres v8.3
我遇到的问题应该很简单.
我有两个用例......
我希望在任何一种情况下都做同样的事情,除非我不想在我的网站使用布局,因为它是iframe所以我有一个"普通"的布局
layout "plain"
Run Code Online (Sandbox Code Playgroud)
如何根据情况动态分配布局..
即params[:iframe] == true 等
我所做的一切似乎都没有用.
我有一个模型Spaces,它有不同类型的地方......如酒吧,餐馆等.它有相同的列,相同,模型,控制器等没有花哨的STI,我只有一个字段叫Space_type我想要确定别名路线.
而不是 domain.com/spaces/12345它/bars/12345或/clubs/12345
目前我有:
resources :spaces do
collection do
get :update_availables
get :update_search
get :autocomplete
end
member do
post :publish
post :scrape
end
resources :photos do
collection do
put :sort
end
end
resources :reviews
end
Run Code Online (Sandbox Code Playgroud)
另外,有没有办法可以做到这一点,以便我随时使用space_url它可以找出使用哪一个?
routes ruby-on-rails url-routing custom-routes ruby-on-rails-3
我可以很容易地重定向,但我想在验证失败时渲染编辑页面,所以我将所有验证方法都转移到表单中.我不确定如何使用active_admin呈现编辑操作.
如果我尝试render :action => 'edit'我得到一个模板缺少页面我也试过render active_admin_template('edit.html.arb'),它给了我一个页面内的页面,但没有错误.
有任何想法吗?
member_action :state do
space = Space.find(params[:id])
if space.send(params[:state])
#space.send(params[:state]+"!")
flash[:notice] = "State Changed!"
redirect_to :action => :index
else
#render :action => 'edit'
#render active_admin_template('edit.html.arb')
flash[:error] = "#{space.errors}"
redirect_to :action => :edit
end
end
Run Code Online (Sandbox Code Playgroud) validation ruby-on-rails renderaction ruby-on-rails-3 activeadmin
我在使用带有active_admin的rails3-jquery-autocomplete gem时遇到问题
我正在使用最新版本的active_admin(来自git),它现在依赖于formtastic 2而我正在使用1.04的rails3-jquery-autocomplete
undefined local variable or method `autocomplete_artist_name_records_path' for #<ActiveAdmin::DSL:0x007fde797140d0>
Run Code Online (Sandbox Code Playgroud)
它不喜欢我提供的网址路线,任何想法我可能做错了什么?
gem 'activeadmin', :git => 'git://github.com/gregbell/active_admin.git'
gem 'rails3-jquery-autocomplete', '~> 1.0.4'
Run Code Online (Sandbox Code Playgroud)
ActiveAdmin.register Record do
#...
controller do
autocomplete :artist, :name#, :full => true
end
form do |f|
f.input :artist_name, :as => :autocomplete, :url => autocomplete_artist_name_records_path
end
end
Run Code Online (Sandbox Code Playgroud)
resources :records do
get :autocomplete_artist_name, :on => :collection
end
Run Code Online (Sandbox Code Playgroud)
我也尝试过这个我在某个地方找到的修复程序,但它没有改变任何东西,包括错误
我最近从Devise 1.2升级到1.4.9,除了我的确认模块外,一切似乎都有效.电子邮件以及整个过程都有效.但确认页面始终为空白.它工作并确认电子邮件帐户,但它不会重定向用户并引发406错误.对于错误确认尝试,它也是如此.
路由似乎工作正常,我已在我的用户模型中指定确认,并且没有其他任何更改.
有任何想法吗?我是否遗漏了一些设置或需要更新1.4.9的内容?
UPDATE
这似乎是生成URL的问题.由于某些未知原因,它是在前面加上确认URL和用户名吗?这导致它破裂.但我仍然不确定如何解决它.
HTTP://本地主机:5000 /用户/ confirmation.someusername confirmation_token = R7apAPhC5c3rszvhsowp
上面的URL中的用户名导致进程无法正常工作.
我检查了1.2(有效)控制器和新版本之间的差异.
# GET /resource/confirmation?confirmation_token=abcdef
def show
self.resource = resource_class.confirm_by_token(params[:confirmation_token])
if resource.errors.empty?
set_flash_message :notice, :confirmed
sign_in_and_redirect(resource_name, resource)
else
render_with_scope :new
end
end
Run Code Online (Sandbox Code Playgroud)
# GET /resource/confirmation?confirmation_token=abcdef
def show
self.resource = resource_class.confirm_by_token(params[:confirmation_token])
if resource.errors.empty?
set_flash_message(:notice, :confirmed) if is_navigational_format?
sign_in(resource_name, resource)
respond_with_navigational(resource){ redirect_to after_confirmation_path_for(resource_name, resource) }
else
respond_with_navigational(resource.errors, :status => :unprocessable_entity){ render_with_scope :new }
end
end
protected
# The path used after resending confirmation instructions.
def after_resending_confirmation_instructions_path_for(resource_name)
new_session_path(resource_name)
end …Run Code Online (Sandbox Code Playgroud) 这可能是一个简单的问题,但我注意到有一些错误来源于空值而不是nils ...
如果用户在标准rails应用程序中将字段留空,是否有办法将数据库中的字段设置为NULL而不是输入空值?
基本上像@ model.info.nil这样的支票?返回true而不是检查它是否为零和空?
我猜这个信息很有特权,因为我在谷歌列出的API上找不到任何东西.事实上,如果它不是专有的固定谷歌魔法我会感到惊讶,但我想我还是会问.
当你做一个女演员或摇滚乐队的基本搜索时,会出现一个Google API吗?如果谷歌确切地确定了您正在寻找的内容,您就会知道结果右侧显示的框.(尽管下面的例子,我对音乐家特别感兴趣)
即
https://www.google.com/search?q=woody+allen

我可以使用Freebase获得类似的milage,但Google总是更好.例如,如果它是音乐家等,它甚至会拉动即将发生的事件.
activeadmin ×2
ruby ×2
alter-table ×1
api ×1
autocomplete ×1
datepicker ×1
devise ×1
freebase ×1
google-api ×1
iframe ×1
jquery ×1
jquery-ui ×1
layout ×1
migration ×1
model ×1
null ×1
postgresql ×1
renderaction ×1
routes ×1
rubygems ×1
types ×1
url-routing ×1
validation ×1