似乎很多其他人在安装pg gem时遇到了问题.没有为他人提出的解决方案对我有用.
我试图安装pg gem和postgres.app.pg gem不会安装.我得到的第一个错误是:
安装pg(0.17.0)时发生错误,Bundler无法继续.gem install pg -v '0.17.0'在捆绑之前确保成功.
关于将我的gem安装指向pg的配置的安装建议失败,并显示以下错误消息(此论坛上的许多其他人遇到过):
Failed to build native extensions... Results logged to /Users/melanie/.rvm/gems/ruby-1.9.3-p448/gems/pg-0.17.0/ext/gem_make.out
Run Code Online (Sandbox Code Playgroud)
我不知道如何查找或访问此日志文件以搜索更多线索.
当我尝试使用sudo apt-get install命令时,我也收到错误消息(找不到命令).在过去的6个小时里,我一直在搜索这个论坛,尝试了每一条建议,让pg与我的rails项目合作.
我找不到关于如何更改路径的建议,或者具体地说,需要进行哪些更改.我which pg_config返回一个文件源.我已经使用命令来使用该配置安装pg.它失败.
有这么多人遇到麻烦.许多答案都表明了自制软件.我不得不删除它,因为它抛出了其他问题.
我想弄清楚如何使用 Firebase 侦听器,以便使用 React 挂钩更新来刷新云 Firestore 数据。
最初,我使用带有 componentDidMount 函数的类组件来获取 firestore 数据。
this.props.firebase.db
.collection('users')
// .doc(this.props.firebase.db.collection('users').doc(this.props.firebase.authUser.uid))
.doc(this.props.firebase.db.collection('users').doc(this.props.authUser.uid))
.get()
.then(doc => {
this.setState({ name: doc.data().name });
// loading: false,
});
}
Run Code Online (Sandbox Code Playgroud)
当页面更新时会中断,所以我试图弄清楚如何移动侦听器以响应钩子。
我已经安装了react-firebase-hooks工具 - 尽管我不知道如何阅读说明才能让它工作。
我有一个功能组件如下:
import React, { useState, useEffect } from 'react';
import { useDocument } from 'react-firebase-hooks/firestore';
import {
BrowserRouter as Router,
Route,
Link,
Switch,
useRouteMatch,
} from 'react-router-dom';
import * as ROUTES from '../../constants/Routes';
import { compose } from 'recompose';
import { withFirebase } from …Run Code Online (Sandbox Code Playgroud) javascript firebase reactjs google-cloud-firestore react-hooks
我想在我的rails 4 app中使用mailboxer.当我尝试部署数据库时出现问题.创建邮箱会话表时出错,该表在通知表中具有依赖关系.
我正在尝试删除通知对话的外键.
我创建了一个迁移说:
change_table :notifications do |t|
t.remove_foreign_key :conversations
Run Code Online (Sandbox Code Playgroud)
但是,rake中止并说外键不存在.
rake aborted!
An error has occurred, this and all later migrations canceled:
PG::UndefinedObject: ERROR: constraint "notifications_conversation_id_fk" of relation "notifications" does not exist
Run Code Online (Sandbox Code Playgroud)
我的架构包括:add_foreign_key"notifications","conversation",name:"notifications_on_conversation_id"
我试图挖掘db:migrate:down创建邮箱的原始迁移,但也收到错误,说'找不到命令'.
有人可以帮忙吗?谢谢.
我花了好几天时间在设计和omniauth上观看RailsCasts,然后通过相关教程来设置使用这些gem的身份验证系统.我认为RailsCasts已经过时了,试图用其他教程修补差距会产生各种各样的问题.
请任何人都可以建议我可以用作实施该系统的基础的当前教程.我有单独的用户和身份验证模型(用户有许多身份验证).
我真的很喜欢在rails 4上使用设计和omniauth(使用CanCan的能力),但是在尝试找到基本设置(使用psql作为数据库)时,我正在撕裂我的头发.
我试图让我的rails 4应用程序中的bootstrap javascript工作.
我问了这些问题,但未能得到任何帮助.
https://stackoverflow.com/questions/33685338/rails-with-bootstrap-tabs
https://stackoverflow.com/questions/33852687/rails-4-bootstrap-date-picker
Run Code Online (Sandbox Code Playgroud)
我越来越感到被这一挑战所打败.令人沮丧的是,bootstrap被描述为一个简单的rails工具.如果有人能帮忙解决这个问题,我很乐意支付100美元.
我的问题是具体的javascript函数.我的标签不起作用.单击链接时,没有任何反应.此外,日期选择器不起作用(我希望日历只需单击一下即可选择日期).
在我的宝石文件中,我有:
gem 'sass-rails', '~> 5.0'
gem 'bootstrap-sass', '~> 3.3.5'
gem 'font-awesome-sass', '~> 4.4.0'
gem 'bootstrap-slider-rails'
gem 'bootstrap-datepicker-rails'
gem 'jquery-rails'
Run Code Online (Sandbox Code Playgroud)
在我的application.html.erb中,我有:
<link href='http://fonts.googleapis.com/css?family=Quicksand|Roboto:300' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Noto+Sans' rel='stylesheet' type='text/css'>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="p:domain_verify" content="44c82789b3dcecac427e4b65123fb68d"/>
<title><%= content_for?(:title) ? yield(:title) : "RE" %></title>
<meta name="description" content="<%= content_for?(:description) ? yield(:description) : "Ae" %>">
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => false %>
<%= javascript_include_tag "application", "data-turbolinks-track" => false %>
<%= csrf_meta_tags %> …Run Code Online (Sandbox Code Playgroud) 我正在尝试配置我的第一个节点反应应用程序.
我一直收到一条错误,上面写着"无法解析babel-loader".
谷歌搜索该错误,我发现了一些不起作用的建议.
第一个是将以下内容添加到我的webpack.config.js中
// resolveLoader: {
// modulesDirectories: '/usr/local/lib/node_modules'
// },
Run Code Online (Sandbox Code Playgroud)
尝试这会产生一个错误,说:
Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
- configuration.resolveLoader has an unknown property 'modulesDirectories'. These properties are valid:
object { alias?, aliasFields?, cachePredicate?, descriptionFiles?, enforceExtension?, enforceModuleExtension?, extensions?, fileSystem?, mainFields?, mainFiles?, moduleExtensions?, modules?, plugins?, resolver?, symlinks?, unsafeCache?, useSyncFileSystemCalls? }
Run Code Online (Sandbox Code Playgroud)
下一个建议是尝试:
resolveLoader: {
fallback: '/usr/local/lib/node_modules'
},
Run Code Online (Sandbox Code Playgroud)
这会产生类似的错误.
有没有人对如何开始使用此配置有任何建议.理解文档很困难 - 每一句话都是行话,我找不到一个参考点来找到对这个设置开始时需要做些什么的基本理解.
Webpack.config.js是:
module.exports = {
entry: './app/app.jsx',
output: { …Run Code Online (Sandbox Code Playgroud) 是否可以将 endAdornment 放入 MaterialUI 中的选择菜单中?
我想将内容添加到选择菜单上向下指针的右侧。
endAdornment={
<InputAdornment position="end">
<Insights />
</InputAdornment>
<Select
labelId="demo-mutiple-name-label"
id="demo-mutiple-name"
multiple
value={fieldName}
onChange={handleChange}
input={<Input id="select-multiple-chip" />}
renderValue={(selected) => (
<div className={classes.chips}>
{selected.map((value) => (
<Chip key={value} label={value} className={classes.chip} />
))}
</div>
)}
MenuProps={MenuProps}
>
{field.map((field) => (
<MenuItem key={field} value={field} >
{field}
</MenuItem>
))}
</Select>
Run Code Online (Sandbox Code Playgroud) 我想弄清楚如何在反应应用程序中显示 firestore 时间戳。
我有一个名为 createdAt 的字段的 firestore 文档。
我试图将它包含在输出列表中(在此处提取相关位,以便您不必通读整个字段列表)。
componentDidMount() {
this.setState({ loading: true });
this.unsubscribe = this.props.firebase
.users()
.onSnapshot(snapshot => {
let users = [];
snapshot.forEach(doc =>
users.push({ ...doc.data(), uid: doc.id }),
);
this.setState({
users,
loading: false,
});
});
}
componentWillUnmount() {
this.unsubscribe();
}
render() {
const { users, loading } = this.state;
return (
<div>
{loading && <div>Loading ...</div>}
{users.map(user => (
<Paragraph key={user.uid}>
<key={user.uid}>
{user.email}
{user.name}
{user.createdAt.toDate()}
{user.createdAt.toDate}
{user.createdAt.toDate()).toDateString()}
Run Code Online (Sandbox Code Playgroud)
唯一不会呈现的属性是日期。
上述每一次尝试都会产生一个错误,说明:
类型错误:无法读取未定义的属性“toDate”
javascript unix-timestamp firebase reactjs google-cloud-firestore
我想在Rails 4中创建一个应用程序.
我试图使用政治家宝石为州,然后专政政策.
我的gemfile有:
gem 'statesman', '~> 1.3', '>= 1.3.1'
gem 'pundit'
Run Code Online (Sandbox Code Playgroud)
我有一篇文章模型和一篇文章转换模型和一篇article_state_machine模型.
我的目标是在我的文章策略中定义发布策略(使用权威),允许拥有文章的用户在该文章处于"已批准"状态时发布该文章.
我在我的权威文章政策中尝试这个:
class ArticlePolicy < ApplicationPolicy
def publish?
user.present? && user == article.user
# if requires approval, then approved
# and article.in_state(:approve) - why doesnt this work - see statesman docs?
# user && user.article.exists?(article.id)
end
end
Run Code Online (Sandbox Code Playgroud)
当我尝试检查文章是否处于状态时:批准(如上所述),我收到一条错误消息,指出未定义的方法'in_state'.
如何在策略中使用状态机?或者是否该策略允许用户始终发布,但是当文章处于州批准状态时,您只在文章显示页面上显示按钮(尽管我认为这是专家的观点).
Article.rb
class Article < ActiveRecord::Base
include Statesman::Adapters::ActiveRecordQueries
has_many :transitions, class_name: "ArticleTransition", autosave: false
def state_machine
@state_machine ||= ArticleStateMachine.new(self, transition_class: ArticleTransition, association_name: :transitions)
end
# delegate :can_transition_to?. :trans
# …Run Code Online (Sandbox Code Playgroud) 我想在你的rails 4 app中加入你的管.
我希望用户能够上传视频文件,然后将其发布到我的管频道上.
我正在使用Rails 4和Youtube_it gem.我一直在尝试遵循这个教程:http://www.sitepoint.com/youtube-rails/
我的文件结构有项目模型和视频模型.协会是:
Project.rb
has_one :video
accepts_nested_attributes_for :video
Run Code Online (Sandbox Code Playgroud)
Video.rb
belongs_to :project
Run Code Online (Sandbox Code Playgroud)
我的视频表有一个名为:include_video的布尔属性.
<%= f.collection_radio_buttons :include_video, [[true, ' Yes'], [false, ' No']], :first, :last, {:item_wrapper_class => 'fixradio'}, {:class => "radio-inline create-project response-project"} %>
Run Code Online (Sandbox Code Playgroud)
如果这是真的,那么我想揭示用户添加视频链接的字段(属性称为:链接).
<%= f.file_field :link %>
Run Code Online (Sandbox Code Playgroud)
我问这些问题的视频表格是部分的.部分是在项目表格内部,其他问题.我还有一个局部视图,其中包含用于管夹的容器(如教程中所示).
视图部分包含在我的项目显示页面中:
<% if @project.video.include_video? %>
<%= render 'videos/particulars' %>
<% end %>
Run Code Online (Sandbox Code Playgroud)
我的项目控制员有:
def new
@project = Project.new
@project.video = Video.new
end
def show
#authorise @project
@project = Project.find(params[:id])
@creator = User.find(@project.creator_id)
@creator_profile = …Run Code Online (Sandbox Code Playgroud) javascript ×3
firebase ×2
reactjs ×2
babeljs ×1
css ×1
devise ×1
foreigner ×1
gem ×1
jquery ×1
macos ×1
mailboxer ×1
material-ui ×1
node-modules ×1
node.js ×1
omniauth ×1
postgresql ×1
psql ×1
pundit ×1
react-hooks ×1
react-select ×1
video ×1
webpack ×1
webpack-2 ×1
youtube ×1