当我调用时rake ts:rebuild RAILS_ENV=production,我得到以下内容:
(in /var/www/abc.com/public/abc/releases/20101008073517)
** Erubis 2.6.6
Stopped search daemon (pid 22531).
Generating Configuration to /var/www/abc.com/public/abc/releases/20101008073517/config/production.sphinx.conf
Sphinx 1.10-beta (r2420)
Copyright (c) 2001-2010, Andrew Aksyonoff
Copyright (c) 2008-2010, Sphinx Technologies Inc (http://sphinxsearch.com)
using config file '/var/www/abc.com/public/abc/releases/20101008073517/config/production.sphinx.conf'...
indexing index 'spot_core'...
collected 6 docs, 0.0 MB
sorted 0.0 Mhits, 100.0% done
total 6 docs, 4622 bytes
total 0.016 sec, 278316 bytes/sec, 361.29 docs/sec
skipping non-plain index 'spot'...
indexing index 'trip_core'...
collected 3 docs, 0.0 MB
sorted 0.0 Mhits, 100.0% done …Run Code Online (Sandbox Code Playgroud) 我有以下代码:
// Autocomplete search
$("#shop_search").autocomplete({
source: '<%= spotify_search_path(:json) %>',
minLength: 1,
select: function(event, ui) {
append_place(ui.item.name, ui.item.id, ui.item.shop_type, ui.item.address_geo, ui.item.contact, ui.item.email, ui.item.web);
$("#shop_search").val('');
}
}).data( "autocomplete" )._renderItem = function( ul, item ) {
return $( "<li></li>" )
.data( "item.autocomplete", item )
.append( "<a>" + "<span class='autocomplete_link'>" + item.name + "</span>" + "<br />" + "<span class='autocomplete_address'>" + item.address_geo + "</span>" + "</a>" )
.appendTo( ul );
$(".ui-autocomplete-loading").ajaxStart(function(){
$(this).show();
});
$(".ui-autocomplete-loading").ajaxStop(function(){
$(this).hide();
});
};
Run Code Online (Sandbox Code Playgroud)
目前它只显示搜索结果时的下拉自动完成功能.我想让它显示"找不到匹配项"时找不到任何内容.我应该在代码中添加什么?
谢谢.
由于愚蠢而粗心,我不小心把桌子上的内容丢了.如何在RAils中重新创建该表?试图运行,rake db:migrate但它没有创建一个新表.谢谢.
使用Rails 2.3.8.
我在我的控制器中添加了这个:
filter_parameter_logging :password, :password_confirmation
Run Code Online (Sandbox Code Playgroud)
但是密码仍然显示在我的生产和开发日志中.请指教.
Processing UserSessionsController#create (for 110.159.52.119 at 2011-03-11 18:25:50) [POST]
Parameters: {"user_session"=>{"remember_me"=>"0", "password"=>"therealpassword", "login"=>"usernamehere"}, "action"=>"create", "authenticity_token"=>"kx96Yc9sF/dYbRL8UYni2tp+p/yz6CTHw+j/X6bqh/g=", "controller"=>"user_sessions"}
[paperclip] Saving attachments.
Redirected to http://abc.com/account
Completed in 2047ms (DB: 532) | 302 Found [http://abc.com/user_session]
** Erubis 2.6.6
Run Code Online (Sandbox Code Playgroud)
谢谢.
我关注性能,工程和可读性.假设我有一个博客,每个帖子都有其状态:已发布(4),待审核(2),草稿(1).建议将这些信息存储在status列中?
status <======= storing status as string
========
pending
published
draft
status <======= storing status as integer
========
2
4
1
Run Code Online (Sandbox Code Playgroud)
另外,如果我们应该存储整数,我们应该避免存储运行的整数:1, 2, 3, 4, 5,而不是存储^ 2整数:2, 4, 8, 16, 32?
非常感谢.
这是我在控制器中的功能:
def sort
params[:state].each_with_index do |id, index|
State.update_all({:position => index+1, :country_id => params[:country_id]}, {:id => id})
end
render :nothing => true
end
Run Code Online (Sandbox Code Playgroud)
这是我的输出:
Started POST "/countries/83/states/sort" for 127.0.0.1 at Thu Apr 19 00:02:56 +0800 2012
Processing by StatesController#sort as JS
Parameters: {"country_id"=>"83", "state"=>["378", "381", "380"]}
ApplicationController::current_user_session
Country Load (0.3ms) SELECT `countries`.* FROM `countries` WHERE `countries`.`id` = 83 LIMIT 1
SQL (1.0ms) UPDATE `states` SET `country_id` = '83', `position` = 1 WHERE `states`.`id` = 378
SQL (1.4ms) UPDATE `states` SET `country_id` …Run Code Online (Sandbox Code Playgroud) 我有一个大约有100多万条记录的应用程序.
我知道Redis的自动完成速度非常快,但Solr也有自己的自动完成功能.
问题:我应该使用Solr作为主要搜索引擎(用于非自动完成任务)和单独的Redis进行自动完成,还是我最好只使用Solr来完成这两项任务?
笔记:
谢谢.
我有以下范围:
scope :user_reviews, lambda { |user| where(:user_id => user) }
Run Code Online (Sandbox Code Playgroud)
我在控制器中应用它:
def show
@review = @reviewable.reviews.user_reviews(current_user).first || Review.new
end
Run Code Online (Sandbox Code Playgroud)
这first是限制搜索当前用户的唯一审查.现在我尝试编写一个新的范围user_review,我尝试了许多方法来链接user_reviews范围first,但却无法得到它.像这样的东西:
scope :user_reviews, lambda { |user| where(:user_id => user) }
scope :user_review, lambda { |user| user_reviews(user).first }
Run Code Online (Sandbox Code Playgroud)
我知道上面user_review的错误,但只是想告诉你们我想做什么.
我应该如何正确地写这个?
谢谢.
如果我有这个SCSS:
$a: #fff;
$b: #fff;
$c: #fff;
$d: #fff;
Run Code Online (Sandbox Code Playgroud)
这有什么捷径吗?
使用 MySQL(准确地说是 MariaDB)。我有以下脚本需要每隔一天运行一次来更新我的数据库,但它慢得令人无法忍受。要更新的每个表都需要运行数小时。这是一个shell脚本:
CMD_MYSQL="${MYSQL_DIR}mysql --local-infile=1 --default-character-set=utf8 --protocol=${MYSQL_PROTOCOL} --port=${MYSQL_PORT} --user=${MYSQL_USER} --pass=${MYSQL_PASS} --host=${MYSQL_HOST} --database=${MYSQL_DB}"
### Update MySQL Data ###
## table name are lowercase
tablename=`echo $FILE | tr "[[:upper:]]" "[[:lower:]]"`
echo "Uploading ($FILE) to ($MYSQL_DB.$tablename) with REPLACE option..."
## let's try with the REPLACE OPTION
$CMD_MYSQL --execute="LOAD DATA LOCAL INFILE '$FILE.txt' REPLACE INTO TABLE $tablename CHARACTER SET utf8 FIELDS TERMINATED BY '|' IGNORE 1 LINES;"
## we need to erase the records, NOT updated today
echo "erasing old records from …Run Code Online (Sandbox Code Playgroud)