我试图让省略号像这样工作:http://jsfiddle.net/583mK/1/
有趣的是,它在jsFiddle上工作得很好.奇怪的是给出了完全相同的HTML/CSS它不能在我的应用程序上工作,我无法弄清楚为什么.是否有任何省略号可能导致这种情况?
一个很大的区别在于小提琴,它是所有静态内容.在我的应用程序中,页面加载,jQuery模板用于填充列表,然后我想要一个省略号.
文本没有溢出,因此溢出工作正常,并且空白区域正在工作,而不是...省略号.
通常,我向github签入代码的工作流程是:
git add .
git commit -a -m "description"
git push
Run Code Online (Sandbox Code Playgroud)
这一直都有效.但现在当我提交时,我收到此错误:
$ git commit -a -m "x"
# On branch master
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# ../db/migrate/20110506232317_add_xxxxxxxx.rb
# ../lib/xxxxxxxx_job.rb
nothing added to commit but untracked files present (use "git add" to track)
Run Code Online (Sandbox Code Playgroud)
并重新使用git add.没有效果.有什么想法在这里发生了什么?谢谢
我有很长的group_ids列表,如下所示:
@group_ids = @groups.map(&:group_id)
Rails.logger.info @group_ids
[182, 122, 181, 173, 167, 58, 13, 11, 180, 40, 71, 1, 29, 47, 142, 52, 174, 7, 168, 171, 156, 120, 79, 72, 54, 26, 65]
Run Code Online (Sandbox Code Playgroud)
如何获取所有group_ids和输出:
group_id:11 OR group_id:22 etc
Run Code Online (Sandbox Code Playgroud) 这是设置:
模型
class ListItem < ActiveRecord::Base
belongs_to :list
validates :title, :presence => true, :length => { :minimum => 1 }
end
Run Code Online (Sandbox Code Playgroud)
调节器
# POST /list_items
# POST /list_items.xml
def create
@list = List.find(params[:list_id])
@list_item = @list.list_items.build(params[:list_item].merge(:user_id => current_user.id))
respond_to do |format|
if @list_item.save
format.js
else
render :js => "alert('enter at least one character please!');"
end
end
end
Run Code Online (Sandbox Code Playgroud)
填充list_item.title时,它可以正常工作.当提交长度为0的list_item.title时,它不会正常失败.在日志中我看到:
Started POST "/lists/7/list_items" for 127.0.0.1 at Wed Jun 29 18:04:26 -0700 2011
Processing by ListItemsController#create as
Parameters: {"list_item"=>{"completed"=>"0", "title"=>""}, "authenticity_token"=>"9yJ9yBo883gEOhl0lKkTzDMTDLXg/Fjx5e9wYonf3yE=", "utf8"=>"?", "list_id"=>"7"} …Run Code Online (Sandbox Code Playgroud) 使用设计,我有一个用户模型.我没有用户控制器.
要使用CanCan,我需要在控制器顶部(下方)执行此操作
# Authorization w Devise & CanCan
before_filter :authenticate_user! # Devise, signed in users only
load_and_authorize_resource # CanCan
Run Code Online (Sandbox Code Playgroud)
我在哪里添加这个,所以我可以拥有用户模型的权限,因为我没有用户控制器?
谢谢
现在,如果我有像@user这样的用户对象.
我可以做@ user.to_json
我想要做的是为json对象rails创建添加值.我试过这个:
@user.attributes.merge{ :catalyst_show => true }
Run Code Online (Sandbox Code Playgroud)
但是语法错误的错误,意外的tASSOC,期待'}'
关于如何向json对象添加属性的任何想法?
谢谢
我有一个Message.uuid字段,我想添加验证,其中包括:
支持的:
rails为这些规则编写模型验证的最佳方法是什么?
谢谢
更新:
validates :uuid,
:length => { :within => 5..500 },
:format => { :with => /[A-Za-z\d][-A-Za-z\d]{3,498}[A-Za-z\d]/ }
Run Code Online (Sandbox Code Playgroud)
使用有效的UUID,这是失败的
鉴于这种:
if (params[:to].to_s =~ (/^r\+.*@site.com$/)) == nil
Run Code Online (Sandbox Code Playgroud)
如何使site.com动态: #{SITE_CONFIG['mail_host']}
我试过了
if (params[:to].to_s =~ (/^r\+.*@#{SITE_CONFIG['mail_host']}$/)) == nil
Run Code Online (Sandbox Code Playgroud)
哪个没用..想法?
我目前正在使用: gem "omniauth", '0.3.2'
我正在尝试升级到omniauth 1.0.0,将以上内容替换为:
gem 'omniauth-github', :git => 'git://github.com/intridea/omniauth-github.git' # Core, requires a OA Stratedgy gem for each provider
gem 'omniauth-facebook', :git => 'git://github.com/mkdynamic/omniauth-facebook.git' # FB OmmiAuth Stratedgy
gem 'omniauth-contrib', :git => 'git://github.com/intridea/omniauth-contrib.git' # TWITTER OmmiAuth Stratedgy
Run Code Online (Sandbox Code Playgroud)
但是当我捆绑安装/更新时遇到错误:
$ bundle install
Updating git://github.com/intridea/omniauth-github.git
Updating git://github.com/mkdynamic/omniauth-facebook.git
Updating git://github.com/intridea/omniauth-contrib.git
Fetching source index for http://rubygems.org/
Bundler could not find compatible versions for gem "hashie":
In snapshot (Gemfile.lock):
hashie (1.1.0)
In Gemfile:
omniauth-facebook depends on
hashie (~> 1.2)
Running `bundle update` will …Run Code Online (Sandbox Code Playgroud)