我正在尝试为开发和测试创建postgres数据库.
我正在使用...
的Gemfile ...
gem 'pg'
Run Code Online (Sandbox Code Playgroud)
database.yml的
default: &default
adapter: postgresql
encoding: unicode
pool: 5
development:
<<: *default
database: myapp_development
username: username
password:
test:
<<: *default
database: myapp_test
Run Code Online (Sandbox Code Playgroud)
rake db:create:all 回报
PG::InsufficientPrivilege: ERROR: permission denied to create database
: CREATE DATABASE "myapp_development" ENCODING = 'unicode'
.... (lots of tracing)
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "pool"=>5, "database"=>"myapp_development", "username"=>"username", "password"=>nil}
myapp_test already exists
Run Code Online (Sandbox Code Playgroud)
怎么了?
编辑
我只是尝试将database.yml中的用户名更改为我在Mac上使用的用户名.有效.它还告诉我,不仅maybe_test' already exists, but it also just told …
我这里有一个简单的问题.我有一个带有created_at的实例变量.我将如何将其转换为 Month, day, year ~ September, 13, 1987
当我试着= @ example.created_at在我看来它给了我 1987-09-13
奇怪的是,当我在控制台中执行此方法时,我得到了 Sun, 13 Sep 1987
我有一个带有链接的导航栏。“品牌”链接有效,但没有任何ul作用。我已经阅读了有关e.preventDefault();问题的知识$('ul.nav > li').click(function (e) {。我还阅读了与之相关的文章z-index。我没有发现任何这种情况(除非我找不到嵌入在js应用程序加载的文件中并且不在我的Assets文件夹中的文件)。
是什么原因造成的?
我不确定它是否在css或js文件中。另外,切换功能还不错,它只是活动链接。
<head>
<title>Welcome</title>
<meta charset='utf-8'>
<meta content='IE=edge' http-equiv='X-UA-Compatible'>
<meta content='width=device-width, initial-scale=1' name='viewport'>
<meta content='' name='description'>
<meta content='' name='author'>
<meta name="csrf-param" content="authenticity_token" />
<meta name="csrf-token" content="PZfcHJlhwRF4SMTlLODmWg4gv/d8eli2VqnZm1i/dnjyUhKjUkZXq+2jeMjfU/eYiArG5oU0Ur1VG6GLBYik6Q==" />
<link rel="stylesheet" media="screen" href="/assets/rails_bootstrap_forms-85a44da0cf14906976bde10ea0a42bbc.css?body=1" />
<link rel="stylesheet" media="screen" href="/assets/application-7b065b027fe33201010948bc34f4a7db.css?body=1" />
<link rel="stylesheet" media="screen" href="/assets/font-awesome.min-c657d02924cca8259559612983a6a227.css?body=1" />
<link rel="stylesheet" media="screen" href="/assets/modern-business-788410311885bd8eb9a8a947b93e1c6f.css?body=1" />
<script src="/assets/bootstrap-f069863cd7c15927c7faef4bba9fc907.js?body=1"></script>
<script src="/assets/bootstrap.min-759065b3d223bc01ce2f7ad79e06c909.js?body=1"></script>
<script src="/assets/contact_me-55e60d5e2f601e0adf79fc9dea175bf3.js?body=1"></script>
<script src="/assets/jqBootstrapValidation-d5764d00e4f4b8d79882008d22d482fa.js?body=1"></script>
<script src="/assets/jquery-89fdfdd2b961da1c1dac57e8beeff312.js?body=1"></script>
<script src="/assets/application-467c055a5b9b03c420678f7bae6bd21f.js?body=1"></script>
<!-- HTML5 …Run Code Online (Sandbox Code Playgroud) 我收到这个错误,这让我感到困扰.我不知道发生了什么......我已按照T的说明进行操作,但仍在抱怨 - 请帮助!我有错误消息,控制器文件,登录页面和路由文件的摘录.
NoMethodError in User_sessions#new
Showing app/views/user_sessions/new.html.erb where line #4 raised:
undefined method `user_sessions_path' for #<ActionView::Base:0x1fe766f>
Run Code Online (Sandbox Code Playgroud)
提取的来源(第4行):
4. <% form_for @user_session do |f| %>
5. <%= f.error_messages %>
Run Code Online (Sandbox Code Playgroud)
class UserSessionsController < ApplicationController
before_filter :require_no_user, :only => [:new, :create]
before_filter :require_user, :only => :destroy
def new
@user_session = UserSession.new
end
def create
@user_session = UserSession.new(params[:user_session])
if @user_session.save
flash[:notice] = "Login successful!"
redirect_to root_url
#redirect_back_or_default account_url
else
render :action => :new
end
end
def destroy
current_user_session.destroy …Run Code Online (Sandbox Code Playgroud) 我对'响应'的错误是...
规格/功能/ test_name_spec.rb
require "spec_helper"
describe "the signin process", :type => :feature do
it "does not sign me in if I use the wrong password" do
visit '/users/sign_in'
within("#new_user") do
user = Fabricate(:user, email: 'user@example.com', password: 'password')
fill_in 'Email', :with => 'user@ example.com'
fill_in 'Password', :with => 'badone'
end
click_button 'Log in'
expect(response).to render_template(:new)
end
end
Run Code Online (Sandbox Code Playgroud)
宝石文件
group :test do
gem 'shoulda-matchers', '~> 2.8', require: false # now loaded inside of spec/spec_helper.rb
gem 'capybara', '~>2.4'
gem 'launchy'
gem 'capybara-email', github: …Run Code Online (Sandbox Code Playgroud) Uncaught SyntaxError: Unexpected token <我在通过 js 进行部分渲染时遇到错误。该部分仅包含一个表。
正在调用部分,但浏览器控制台中的错误消息将<表标记的第一个显示为意外标记。
<table class='table table-sm'> # <- this line errors
<thead>
<tr>
<th>Part #</th>
<th>Description</th>
<th>Qty</th>
</tr>
</thead>
<tbody>
<tr>
<td>SCS-#10-24X.375-BLK</td>
<td>Countersunk screw, #10-24 X .375, Black oxide</td>
<td>2.0</td>
</tr>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
_check_it.html.haml
- if @part.part_structures == 0
No components
- else
%table.table.table-sm
%thead
%tr
%th Part #
%th Description
%th Qty
%tbody
- @part.part_structures.each do |ps|
%tr
%td= ps.component.partNo
%td= ps.component.description
%td= ps.qty
Run Code Online (Sandbox Code Playgroud)
check_it.js.erb
$("#that_one").replace("<%= j render(partial: 'check_it') %>");
Run Code Online (Sandbox Code Playgroud)
零件控制器.rb …
我正在尝试使用 Entity Framework Core UseInMemoryDatabase 编写测试,因此我的设置如下所示:
[SetUp]
public void Setup()
{
this.ContextOptions = new DbContextOptionsBuilder<GeneralContext>()
.UseInMemoryDatabase(databaseName: "DiagAc2Tests")
.Options;
}
Run Code Online (Sandbox Code Playgroud)
我不知道是否需要,但上下文如下:
public class GeneralContext : DbContext
{
public DbSet<Entities.Application> Applications { get; set; }
public GeneralContext() { }
public GeneralContext(DbContextOptions<GeneralContext> options) : base(options) { }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
var config = new DatabaseConfiguration();
optionsBuilder.UseNpgsql(config.GetConnectionString());
}
}
Run Code Online (Sandbox Code Playgroud)
我在整个应用程序中使用此上下文并且它有效,所以我的测试如下所示:
public async Task CreateApplicationByService()
{
Mock<DTO.IApplication> mock = new Mock<DTO.IApplication>();
mock.SetupProperty(f => f.Name, "Application");
mock.SetupProperty(f => f.ProjectId, 666);
mock.SetupProperty(f => f.ConfigFilePath, …Run Code Online (Sandbox Code Playgroud) 我在一个区域托管了一个 API 控制器。但是,路由似乎不起作用,因为我的 ajax 调用在尝试点击控制器操作时不断返回 404。控制器构造函数中的断点永远不会被击中。
[Area("WorldBuilder")]
[Route("api/[controller]")]
[ApiController]
public class WorldApiController : ControllerBase
{
IWorldService _worldService;
IUserRepository _userRepository;
public WorldApiController(IWorldService worldService, IUserRepository userRepository)
{
_worldService = worldService;
_userRepository = userRepository;
}
[HttpGet]
public ActionResult<WorldIndexViewModel> RegionSetSearch()
{
string searchTerm = null;
var userId = User.GetUserId();
WorldIndexViewModel model = new WorldIndexViewModel();
IEnumerable<UserModel> users = _userRepository.GetUsers();
UserModel defaultUser = new UserModel(new Microsoft.AspNetCore.Identity.IdentityUser("UNKNOWN"), new List<Claim>());
model.OwnedRegionSets = _worldService.GetOwnedRegionSets(userId, searchTerm);
var editableRegionSets = _worldService.GetEditableRegionSets(userId, searchTerm);
if (editableRegionSets != null)
{
model.EditableRegionSets = editableRegionSets.GroupBy(rs => …Run Code Online (Sandbox Code Playgroud) 我有一个JavaScript函数,无法按顺序触发。它先触发CheckForAddRecordsToAddFromDSS方法,然后触发if (check1 || check2)语句,甚至触发CheckForMissingRecordsFromSupp方法。
为什么会这样呢?
$.getJSON("/Home/CheckForMissingRecordsFromSupp", function (data) {
check1 = data;
}).done($.getJSON("/Home/CheckForAddRecordsToAddFromDSS", function (data) {
check2 = data;
}).done(function () {
if (check1 || check2) {
location.reload();
}
})
);
Run Code Online (Sandbox Code Playgroud) ruby ×3
javascript ×2
.net-core ×1
ajax ×1
css ×1
html ×1
jquery ×1
json ×1
postgresql ×1
rspec ×1