我检查了一大堆文件到一个分支并合并,然后不得不删除它们,现在我留下了一个大的.pack文件,我不知道如何摆脱.
我删除了所有使用的文件git rm -rf xxxxxx
,我也运行了该--cached
选项.
有人能告诉我如何删除当前位于以下目录中的大型.pack文件:
.git/objects/pack/pack-xxxxxxxxxxxxxxxxx.pack
我只需要删除我仍然拥有但不再使用的分支吗?或者我还需要运行其他东西吗?
我不确定它有多大差别,但它显示了一个挂锁文件.
谢谢
编辑
以下是我的bash_history的一些摘录,它应该让我知道我是如何设法进入这种状态的(假设我正在开发一个名为'my-branch'的git分支,我有一个包含更多文件夹的文件夹/文件):
git add .
git commit -m "Adding my branch changes to master"
git checkout master
git merge my-branch
git rm -rf unwanted_folder/
rm -rf unwanted_folder/ (not sure why I ran this as well but I did)
Run Code Online (Sandbox Code Playgroud)
我以为我也运行了以下内容,但它没有出现在bash_history中与其他人:
git rm -rf --cached unwanted_folder/
Run Code Online (Sandbox Code Playgroud)
我还以为我运行了一些git命令(比如git gc
)来尝试整理包文件,但它们也没有出现在.bash_history文件中.
我有一个rails应用程序:
user has_many :projects
user has_many :tasks, :through => :projects
project has_many :tasks
每项任务都有一个里程碑日期.
要显示我正在使用的下一个里程碑日期的项目详细信息表:
@projects = current_user.tasks.joins(:project).select("distinct on (projects.id) projects.*, tasks.*").reorder("projects.id, tasks.milestone ASC")
Run Code Online (Sandbox Code Playgroud)
这很好用.
我现在希望能够对表列进行排序.
根据Postgres DISTINCT ON
不可排序,你必须将它包装在另一个select语句中,即SELECT * FROM (SELECT DISTINCT ON....) ORDER BY column_3
我确实认为订购的列可以根据需要在SQL中使用,即(按项目名称DESC排序):
@projects = current_user.tasks.joins(:project).select("distinct on (projects.name) projects.*, tasks.*").reorder("projects.name DESC, tasks.milestone ASC")
Run Code Online (Sandbox Code Playgroud)
哪个有效,但我也希望能够通过里程碑进行排序,但这样做不起作用.
有人能告诉我如何转换我的rails查询,以便可以通过任何列进行排序吗?
UPDATE
我想我的问题很简单我怎么在周围包裹一个ActiveRecord的查询SELECT
和ORDER BY
?
我想我已经成功实现了它:
inner_query = current_user.tasks.select("distinct on (projects.id) projects.*, tasks.*").reorder("projects.id, tasks.milestone ASC").to_sql
@projects = Task.paginate_by_sql("select * from (#{inner_query}) as user_projects order by user_projects.name", …
Run Code Online (Sandbox Code Playgroud) 我在运行rails服务器的同时更新了一个gem,现在我在gemset中安装了两个版本的gem.
我更新了使用bundle update bootstrap-sass
,现在有两个2.0.1
和2.0.2
.
服务器似乎正在提供2.0.1版本,所以我认为它应该在更新时删除了2.0.1版本而不是因为当时正在使用gem.
有人可以告诉我如何正确更新它,以便服务器将使用2.0.2而不是2.0.1或如何删除宝石的2.0.1版本.
我已经注意到关于谷歌弃用引用的消息,place_id
并且正在寻求实现它.
我正在使用AutocompleteService
但是当我运行它时,响应不包含place_id
,但确实包含reference
和id
.
这是我对示例页面做的快速改编(我试图把它放在jsfiddle但是无法让它运行):
<!DOCTYPE html>
<html>
<head>
<title>Retrieving Autocomplete Predictions</title>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?libraries=places"></script>
<script>
// This example retrieves autocomplete predictions programmatically
// from the autocomplete service, and displays them as an HTML list.
// The predictions will include a mix of places (as defined by the
// Google Places API) and suggested search terms.
function initialize() {
var service = new google.maps.places.AutocompleteService();
service.getQueryPredictions({ input: 'trafalgar square' }, callback);
}
function …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用turbolinks 5找到一种处理rails(v4.1)flash消息的方法.
我尝试添加data-temporary="true"
到每个flash消息div,然后像:
$(document).on('turbolinks:before-cache', function () {
$('[data-temporary]').remove();
});
Run Code Online (Sandbox Code Playgroud)
所以旧的flash消息不会被缓存,并且在用户下次访问同一页面时不会显示.
但是,这使我在我正在使用的页面上出现问题,flash.now
因为在这些页面上,flash已从缓存版本中删除,但随后turbolinks刷新服务器中的内容,flash.now
然后出现消息,这有点不和用户观点.
我已经环顾四周,无法找到闪光灯的任何内容,以表明它们是否.now
存在,以便data-temporary
可以应用于临时闪光灯.
我正在尝试使用turbolink而不是禁用它的功能.
我正试图找到一种方法来删除闪光before-cache
但不是如果它们是flash.now
类型.
有什么建议?
我的控制器中有两种方法用于查找用户(注意范围enabled_only
):
before_filter :find_user, :only => :show
before_filter :find_any_user, :only => [:edit, :update, :destroy]
def find_user
@user = User.enabled_only.find(params[:id])
rescue ActiveRecord::RecordNotFound
flash[:alert] = "The user you were looking for could not be found"
redirect_to root_path
end
def find_any_user
@user = User.find(params[:id])
rescue ActiveRecord::RecordNotFound
flash[:alert] = "The user you were looking for could not be found"
redirect_to root_path
end
Run Code Online (Sandbox Code Playgroud)
当然,这些可以合并到一种检查是否存在错误的方法中,:action == 'show'
但我无法采取救援措施来捕获错误。我尝试了类似以下的方法,但没有成功:
before_filter :find_user, :only => [:show, :edit, :update, :destroy]
def find_user
@user = if :action == 'show' …
Run Code Online (Sandbox Code Playgroud) activerecord ×1
bundler ×1
controller ×1
distinct-on ×1
gem ×1
git ×1
google-maps ×1
pack ×1
rescue ×1
rvm ×1
sql-order-by ×1
turbolinks-5 ×1