我有3个C#项目A,B和C.A和B都引用C.对A和B的C的引用设置为"Copy Local",暗示在C之后构建到C.dll(在C的输出目录中) C),它被复制到A或B的输出目录(无论哪个编译)
我有2个解决方案,SA和SB.SA包含A和C,SB包含B和C.我启动了Visual Studio 2015的2个实例.我在一个实例中打开SA,在另一个实例中打开SB.
我发现如果我从SA开始调试(F5)A,然后(当A仍在调试时),从SB更改C并尝试编译SB,我收到一个编译错误,说明C.dll不能被覆盖,因为它正在被另一个进程(运行SA的devenv.exe实例)使用.
这对我没有意义,因为在将C编译为C.dll并复制到A的输出目录之后,Visual Studio应该释放对该文件的锁定.
我已经验证(通过SA中的Modules窗口)已加载的C.dll版本是已复制到A的输出目录的版本.
这开始于我昨天开始使用Visual Studio 2015(而不是Visual Studio 2013)时.
有没有人有任何想法?我目前的解决方案是通过CTRL-F5运行SA(无需调试即可启动),但是当我想同时在调试模式下运行SA和SB时,这会变得很烦人.
谢谢.
UPDATE
我做了一些研究,为什么"编辑并继续"功能可能会导致所描述的行为,并根据此页面https://msdn.microsoft.com/en-us/library/ms164926.aspx >编辑并继续允许一个在调试会话中进行源代码修改,并使结果生效,而不必停止调试,重新编译和重新启动调试会话(这是一个多么严重的问题).启用该功能后,Visual Studio可能需要随时重新编译任何相关DLL,以解释锁定.
我们编写了一个程序,通过它我们试图找到一个常量的地址.有可能这样做吗?
package main
func main() {
const k = 5
address := &k
}
Run Code Online (Sandbox Code Playgroud)
它给出了一个错误,任何人都可以告诉我们如何找到常量的地址?
我正在阅读The Rails 4的方式(由Obie Fernandez撰写),一本关于Rails的着名书籍,从我到目前为止所阅读的内容,我强烈推荐它.
但是,有一个示例部分9.2.7.1:一个类中的多个回调方法让我困惑:
忍受我,为了让每个人都明白这个问题,我已经复制了本书在这个问题中描述的步骤.
关于活动记录的回调(本节谈判before_create,before_update等等),并且它可以创建一个能处理多种回调为你的类.列出的代码如下:
class Auditor
def initialize(audit_log)
@audit_log = audit_log
end
def after_create(model)
@audit_log.created(model.inspect)
end
def after_update(model)
@audit_log.updated(model.inspect)
end
def after_destroy(model)
@audit_log.destroyed(model.inspect)
end
end
Run Code Online (Sandbox Code Playgroud)
该书说,要将此审核日志记录添加到Active Record类,您将执行以下操作:
class Account < ActiveRecord::Base
after_create Auditor.new(DEFAULT_AUDIT_LOG)
after_update Auditor.new(DEFAULT_AUDIT_LOG)
after_destroy Auditor.new(DEFAULT_AUDIT_LOG)
...
end
Run Code Online (Sandbox Code Playgroud)
然后,本书指出这段代码非常难看,不得不在三行上添加三个审核员,而且它不干.然后继续告诉我们,要解决这个问题,我们应该将一个acts_as_audited方法修补到Active Record::Base对象中,如下所示:
(这本书建议把这个文件放进去/lib/core_ext/active_record_base.rb)
class ActiveRecord::Base
def self.acts_as_audited(audit_log=DEFAULT_AUDIT_LOG)
auditor = Auditor.new(audit_log)
after_create auditor
after_update auditor
after_destroy auditor
end
end …Run Code Online (Sandbox Code Playgroud) 我是Rails和ActiveAdmin的新手.
我希望有一个类似Django管理员的界面,我的应用程序模型,所以我可以管理产品和其他东西.
到目前为止,我有admin_users我可以在我的应用程序中添加或删除管理员用户的URL,这太棒了.
我正在使用Rails 3,我想知道我是否可以添加除用户之外的新菜单,以便我可以管理其他模型 dashboard
我试过了 rails generate active_admin:resource Product
它创建一个名为product.rbon 的文件,app/admin/但它不起作用,这是我的Product模型product.rb
class Product < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable,
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me
belongs_to :category
has_many :line_items
has_many :orders, through: :line_items
validates_presence_of :category_id, :name, :price_cents
attr_accessible :avatar
has_attached_file :avatar, :styles => { :medium …Run Code Online (Sandbox Code Playgroud) Google plus 登录在桌面浏览器上运行良好,但在移动浏览器上运行不正常。网站
链接
var client_id = gmail_client_id;
var scope = gmail_scope;
var apiKey = google_api_key;
function handleClientLoad() {
gapi.client.setApiKey(apiKey);
window.setTimeout(checkAuth,1);
}
function checkAuth() {
gapi.auth.authorize({client_id: client_id, scope: scope, immediate: true}, handleAuthResult);
}
function handleAuthResult(authResult) {
if (authResult && !authResult.error) {
access_token = authResult.access_token;
makeApiCall();
} else {
handleAuthClick();
}
}
function handleAuthClick(event) {
gapi.auth.authorize({client_id: client_id, scope: scope, immediate: false}, handleAuthResult);
return false;
}
function makeApiCall() {
gapi.client.load('oauth2', 'v2', function() {
var request = gapi.client.oauth2.userinfo.get();
request.execute(function(resp) {
checkGoogleUserExist(resp);
}); …Run Code Online (Sandbox Code Playgroud) 根据指南:
...在扩展名为.builder,.rb,.erb,.haml和.slim的文件中完成,用于默认和自定义注释.
但即使手动配置,它也无法正常工作:
$ rails -v
Rails 4.2.3
$ grep -r annotations config/environments/development.rb
config/environments/development.rb: config.annotations.register_extensions('haml') { |a| /#\s*(#{a}):?\s*(.*)$/ }
$ grep -r TODO app/views
app/views/orders/show.html.haml: -# TODO: Add link
$ rake notes
app/models/order.rb:
* [12] [TODO] Refactor
Run Code Online (Sandbox Code Playgroud)
有谁知道如何让它工作?
我gobalize在Rails 4.1.12中使用gem 4.0.3.
我有一个Post模型,我运行Post.create_translation_table!提供的迁移globalize来设置一个post_translations表.
现在我想自动加载夹具文件的翻译.Fixtures支持关联的标签引用,所以我有这个:
# spec/fixtures/posts.yml
my_first_post:
author: dave
# spec/fixtures/post_translations.yml
my_first_post_translation:
locale: en
title: My first post
content: What a time to be alive!
post: my_first_post
# spec/models/post_spec
require 'rails_helper'
RSpec.describe Post, type: :model do
fixtures('post/translations', :posts, :authors)
subject(:post) { posts(:my_first_post) }
it "has an author" do
expect(post.author).to eq(authors(:dave))
end
it "has a title" do
binding.pry
expect(post.title).to be_present
end
end
Run Code Online (Sandbox Code Playgroud)
但运行RSpec会引发以下错误:
Failure/Error: Unable to find matching …Run Code Online (Sandbox Code Playgroud) activerecord ruby-on-rails fixtures ruby-on-rails-4 globalize
我正在使用Semantic-UI来设计我的rails应用程序设计.我创建了一个卡片布局,并在该卡的底部附有一个按钮.但是当我尝试将link_to或button_to添加到底部附加按钮中的文本时,一切都变得糟透了.
<div class="ui four cards">
<a class="red card">
<div class="image">
<%= image_tag("white-image.png") %>
</div>
<div class="ui bottom attached button">
<i class="fa fa-cloud-upload"></i><span class="little-space"></span><%= link_to 'Deploy', controller: 'apps', action: 'show'%>
</div>
</a>
</div>
Run Code Online (Sandbox Code Playgroud)
输出:
必须看起来像这样:
普通的HTML和CSS工作,但当我尝试使用像"link_to"或"button_to"这样的Rails4.2助手时,一切都会出错.有没有什么方法可以使用Rails helper使整个卡片布局可点击.
生成的HTML代码:
<div class="ui four cards">
<a class="red card">
<div class="image">
<img src="/assets/white-image-d3f1bf0d70bdd663809bc001a778b550fc7246e81a614f3ff10e7cfb0a1514cf.png" alt="White image d3f1bf0d70bdd663809bc001a778b550fc7246e81a614f3ff10e7cfb0a1514cf">
</div>
</a><div class="ui bottom attached button"><a class="red card">
<i class="fa fa-cloud-upload"></i><span class="little-space"></span></a><a href="/apps/show">Delpoy</a>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
使用HTML和Semantic-UI进行简单输出
<link href="http://semantic-ui.com/dist/semantic.min.css" rel="stylesheet"/>
<script src="http://semantic-ui.com/dist/semantic.min.js"></script>
<div class="ui four cards"> …Run Code Online (Sandbox Code Playgroud)我有一个应用程序,允许用户喜欢一个帖子.当有人喜欢这个帖子时,帖子请求有效,但除非我刷新页面,否则视图不会更新.我坚持这个.这是我到目前为止:
使用Javascript
$('.favorite').on('click', function() {
var $heart = $(this).find('.fa');
$heart.removeClass('fa-heart-o').addClass('fa-heart');
// POST request to server to create favorite in db
$.post('/favorites', {
favorite: { post_id: $(this).attr('data-id') }
},
function(data) {
console.log(data);
});
});
Run Code Online (Sandbox Code Playgroud)
控制器
def create
post = Post.find_by_id(favorite_params[:post_id])
if current_user.favorite_posts.include? post
render json: {}, status: :bad_request
else
@favorite = current_user.favorites.new(favorite_params)
if @favorite.save
render json: @favorite
else
render json: { errors: @favorite.errors.full_messages }, status: :unprocessable_entity
end
end
Run Code Online (Sandbox Code Playgroud)
结束
这是观点
<% if current_user.favorite_posts.include? post %>
<span class="fa fa-heart"> <%= post.favorites.count %></span> …Run Code Online (Sandbox Code Playgroud) 我需要简短的方法来找到我从中获得的相同响应
k = [
{"child_category"=>{"name"=>"Acrylic Fiber", "id"=>3405}},
{"child_category"=>{"name"=>"Aramid Fiber", "id"=>3406}}
]
o = []
m = k.select!{| i| o << i["child_category"]}
o
#=> [{"name"=>"Acrylic Fiber", "id"=>3405}, {"name"=>"Aramid Fiber", "id"=>3406}]
Run Code Online (Sandbox Code Playgroud) ruby ×3
activerecord ×2
activeadmin ×1
ajax ×1
arrays ×1
callback ×1
constants ×1
css ×1
django ×1
dll ×1
fixtures ×1
globalize ×1
go ×1
google-plus ×1
hash ×1
html ×1
inheritance ×1
javascript ×1
jquery ×1
pointers ×1
rake ×1
semantic-ui ×1