小编hol*_*den的帖子

jquery日期选择器分为多个字段

我有通常的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

6
推荐指数
1
解决办法
5872
查看次数

在rails中协同过滤

我正在寻找在rails中甚至可能的示例中进行协同过滤的解决方案.到目前为止,我只发现了acts_as_recommendable看起来很有用,但我注意到它在过去的两年里没有任何更新.

有谁知道任何其他解决方案和/或示例?

ruby rubygems recommendation-engine ruby-on-rails collaborative-filtering

6
推荐指数
1
解决办法
2028
查看次数

如何将表列转换为另一种数据类型

我的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

migration postgresql types ruby-on-rails alter-table

6
推荐指数
1
解决办法
6742
查看次数

为整个控制器使用不同的布局

我遇到的问题应该很简单.

我有两个用例......

  • 用户是该站点
  • 用户正在使用其他网站的iframe

我希望在任何一种情况下都做同样的事情,除非我不想在我的网站使用布局,因为它是iframe所以我有一个"普通"的布局

layout "plain"
Run Code Online (Sandbox Code Playgroud)

如何根据情况动态分配布局..

params[:iframe] == true

我所做的一切似乎都没有用.

iframe layout ruby-on-rails ruby-on-rails-3

6
推荐指数
1
解决办法
3469
查看次数

rails路由别名

我有一个模型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

6
推荐指数
2
解决办法
8043
查看次数

活动管理员渲染编辑页面

我可以很容易地重定向,但我想在验证失败时渲染编辑页面,所以我将所有验证方法都转移到表单中.我不确定如何使用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

6
推荐指数
1
解决办法
8186
查看次数

active_admin使用rails3-jquery-autocomplete gem自动完成

我在使用带有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)

records.rb(active_admin)

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)

的routes.rb

  resources :records do
    get :autocomplete_artist_name, :on => :collection
  end
Run Code Online (Sandbox Code Playgroud)

我也尝试过这个我在某个地方找到的修复程序,但它没有改变任何东西,包括错误

https://gist.github.com/1137340

autocomplete ruby-on-rails ruby-on-rails-3 activeadmin

6
推荐指数
1
解决办法
3981
查看次数

设计确认无法在最新版本中使用

我最近从Devise 1.2升级到1.4.9,除了我的确认模块外,一切似乎都有效.电子邮件以及整个过程都有效.但确认页面始终为空白.它工作并确认电子邮件帐户,但它不会重定向用户并引发406错误.对于错误确认尝试,它也是如此.

路由似乎工作正常,我已在我的用户模型中指定确认,并且没有其他任何更改.

有任何想法吗?我是否遗漏了一些设置或需要更新1.4.9的内容?

UPDATE

这似乎是生成URL的问题.由于某些未知原因,它是在前面加上确认URL和用户名吗?这导致它破裂.但我仍然不确定如何解决它.

HTTP://本地主机:5000 /用户/ confirmation.someusername confirmation_token = R7apAPhC5c3rszvhsowp

上面的URL中的用户名导致进程无法正常工作.

我检查了1.2(有效)控制器和新版本之间的差异.

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)

1.4.9

  # 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)

authentication ruby-on-rails devise ruby-on-rails-3

6
推荐指数
2
解决办法
3108
查看次数

表单中的rails nils

这可能是一个简单的问题,但我注意到有一些错误来源于空值而不是nils ...

如果用户在标准rails应用程序中将字段留空,是否有办法将数据库中的字段设置为NULL而不是输入空值?

基本上像@ model.info.nil这样的支票?返回true而不是检查它是否为零和空?

ruby null model ruby-on-rails

5
推荐指数
1
解决办法
1152
查看次数

谷歌api的光荣信息框?

我猜这个信息很有特权,因为我在谷歌列出的API上找不到任何东西.事实上,如果它不是专有的固定谷歌魔法我会感到惊讶,但我想我还是会问.

当你做一个女演员或摇滚乐队的基本搜索时,会出现一个Google API吗?如果谷歌确切地确定了您正在寻找的内容,您就会知道结果右侧显示的框.(尽管下面的例子,我对音乐家特别感兴趣)

https://www.google.com/search?q=woody+allen

在此输入图像描述

我可以使用Freebase获得类似的milage,但Google总是更好.例如,如果它是音乐家等,它甚至会拉动即将发生的事件.

api freebase google-api

5
推荐指数
1
解决办法
790
查看次数