我正在尝试用Rails 4创建一个应用程序.
我正在寻找角色管理,并希望使用Rolify,因为它支持实例级角色分配.
对于其他看同一个问题的人来说,下面有2个非常好的答案(我只能打一个,但我用了两个).查看下面的lorefnon和Cyb3rDud3答案).我还在搞清楚,但是已经使用数组(如lorefnon节目)和控制器/路由功能(如Cyb3rDud3所示)进行了迁移.
令我感到困惑的是,Rolify gem的所有文档都使用控制台来定义角色.
如何在代码中定义角色?
该板上的其他人提出了一些问题,这些问题暗示他们在db:seeds文件中定义了角色.我不想这样做,因为我想控制谁使用我的种子文件比谁可以创建角色更紧密.
你在哪里做的?
所有示例都显示它是从控制台完成的.我想定义角色的列表,然后我想给角色的权限(我想用评论员对于这部分).
我有一个用户模型.我看到的另一个宝石是角色模型.它要求您在用户模型中创建角色数组.它很明显你应该在Rolify中做到这一点 - 没有一个文件能给你这一步吗?
你在哪里定义角色?
我正在尝试将 Firebase 与我的 React 应用程序一起使用。
我有一个配置如下的文件:
import * as firebase from 'firebase';
const config = {
apiKey: process.env.FIREBASE_API_KEY,
authDomain: process.env.FIREBASE_AUTH_DOMAIN,
databaseURL: process.env.FIREBASE_DB_URL,
projectId: process.env.FIREBASE_PROJECT_ID,
storageBucket: process.env.FIREBASE_STORAGE_BUCKET,
messagingSenderId: process.env.FIREBASE_MESSAGE_ID,
}
if (!firebase.apps.length) {
firebase.initializeApp(config);
}
const database = firebase.database();
const auth = firebase.auth()
export {firebase, auth, database };
Run Code Online (Sandbox Code Playgroud)
当我尝试这样做时,我收到一条错误消息:
FIREBASE 致命错误:无法确定 Firebase 数据库 URL。调用 firebase.initializeApp() 时,请务必包含 databaseURL 选项。
我无法理解此错误,因为我在初始化应用程序的调用中包含了配置。配置包括数据库 URL。
你如何初始化数据库?
我正在尝试使用我在rails应用程序中设置样式的字形图标.
我想让图标成为另一个页面的链接,但不能使用标准的引导程序样式,因为我已经为我的页面样式定制了链接.
我一直收到关键字类错误 - 有谁知道为什么?
谢谢.
我的观点中有以下链接:
<li><%= link_to <span class="glyphicon glyphicon-comment"></span>, page_path('messages') %> </li>
Run Code Online (Sandbox Code Playgroud)
我也有css如下:
span.glyphicon-comment {
vertical-align:middle;
margin:auto;
padding:10px;
font-size: 2em;
text-align: right;
a:link {text-decoration:none; background-color:transparent; color:grey;};
a:visited {text-decoration:none;background-color:transparent; color:grey;};
a:hover {text-decoration:none;background-color:transparent; color:dark grey;};
a:active {text-decoration:none;background-color:transparent; color:grey;};
}
Run Code Online (Sandbox Code Playgroud) 我试着问这个问题 - 并没有找到任何帮助.
http://stackoverflow.com/questions/33493369/rails-devise-omniauth-problems-with-setup
Run Code Online (Sandbox Code Playgroud)
我放弃了尝试解决问题,并制作了一个全新的应用程序,其中没有别的东西,以便我可以尝试减少其他错误干扰的范围.
在我的新应用程序中,当我点击新注册/新用户链接时,我现在收到错误.
我已经按照rails casts教程(已经尝试了大约20个其他人)来进行此设置.1.5年,我仍然在苦苦挣扎.
问题在于控制器中策略的定义方式.我有4个策略(推特,Facebook,谷歌和linkedin),当我尝试点击链接创建这些帐户的新注册时,我目前正在为每个策略收到不同的错误:
对于Twitter:未知操作无法为Users :: AuthenticationsController找到操作'twitter'
对于Facebook:
Given URL is not permitted by the Application configuration: One or more of the given URLs is not permitted by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains.
Run Code Online (Sandbox Code Playgroud)
这个错误是因为我无法弄清楚Facebook的文档.它显示了如何使用js登录Facebook,我试图在Rails中使用gems.我并不担心这个错误.我认为它与我的网站没有被定义为本地主机有关,虽然我找不到任何地方,但在Facebook的开发者控制台中的回调网址.我的问题与这个问题没有关系,我会帮助你解决这个问题.
对于LinkedIn:
Safari can’t open the page “https://www.linkedin.com/uas/oauth2/authorization?client_id=LINKEDIN_DEV_ID&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fusers%2Fauth%2Flinkedin%2Fcallback&response_type=code&scope=r_basicprofile+r_emailaddress&state=3fef961c10410464cd5b0ca49b25112ce53fb65f1a3c794f”.
Run Code Online (Sandbox Code Playgroud)
错误是:"无法解码原始数据"(NSURLErrorDomain:-1015)我有一个oauth2回调定义为:
http://localhost:3000/users/auth/linkedin/callback
Run Code Online (Sandbox Code Playgroud)
我不知道这里打破了什么.
对于谷歌:
translation missing: en.devise.authentications.user.failure
Run Code Online (Sandbox Code Playgroud)
单击此链接时,新注册视图只会刷新,并显示错误消息.我也不知道是什么导致了这个错误.
每个错误都不同.
我的控制器文件夹中有一个名为users的文件夹.在里面我有两个控制器如下:
认证控制器:
class Users::AuthenticationsController < …Run Code Online (Sandbox Code Playgroud) 我正在尝试学习如何在我的Rails 5应用程序中使用多态关联.我最近问了这个问题,但是我编辑了很多次来展示我正在尝试的所有东西,它变得一团糟
我的模型叫做Organization,Proposal和Package :: Bip.
协会是:
组织
has_many :bips, as: :ipable, class_name: Package::Bip
accepts_nested_attributes_for :bips, reject_if: :all_blank, allow_destroy: true
Run Code Online (Sandbox Code Playgroud)
提案
has_many :bips, as: :ipable, class_name: Package::Bip
accepts_nested_attributes_for :bips, reject_if: :all_blank, allow_destroy: true
Run Code Online (Sandbox Code Playgroud)
套票:必必
belongs_to :ipable, :polymorphic => true, optional: true #, inverse_of: :bip
Run Code Online (Sandbox Code Playgroud)
Package :: Bip可以与Organization或Proposal相关联.我正在努力弄清楚如何在我的提案节目中展示仅属于提案的Package :: Bips,以及组织的相同内容.
我的package :: bip表有以下两列:
# ipable_id :integer
# ipable_type :string
Run Code Online (Sandbox Code Playgroud)
ipable_type设置为Proposal或Organization.
在我的提案节目中,我有:
<% if @proposal.bips.present? %>
<%#= render @proposal.bips %>
<%= link_to proposal_package_bips_path(@proposal) do %>
<% end %>
<% end %> …Run Code Online (Sandbox Code Playgroud) 我正在尝试按照此处的说明使用firebase ui设置firebase auth.
我用纱线添加了firebase ui模块.我的反应应用程序中的根目录中有一个firebase文件夹.在其中,我有一个firebase.js文件:
import * as firebase from 'firebase';
import * as firebaseui from 'firebaseui'
const config = {
apiKey: process.env.FIREBASE_API_KEY,
authDomain: process.env.FIREBASE_AUTH_DOMAIN,
databaseURL: process.env.FIREBASE_DATABASE_URL,
projectId: process.env.FIREBASE_PROJECT_ID,
storageBucket: process.env.FIREBASE_STORAGE_BUCKET,
messagingSenderId: process.env.FIREBASE_MESSAGING_SENDER_ID
};
firebase.initializeApp(config);
const database = firebase.database();
firebase.auth().createUserWithEmailAndPassword(email, password).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// ...
});
Run Code Online (Sandbox Code Playgroud)
当我尝试检查我是否正确时,我收到一个控制台错误,指出:
firebaseApp.js:339 Uncaught FirebaseError {code: "app/duplicate-service", message: "Firebase: Firebase service named 'auth' already registered (app/duplicate-service).", name: "auth", stack: "auth: Firebase: Firebase …Run Code Online (Sandbox Code Playgroud) 我正在尝试将Fontawesome专业版添加到我的反应应用中.
我在Font Awesome的入门标签上尝试了几乎所有的选项 - 所有产生的都是免费品牌.所以 - 现在我有一个混搭的尝试,并且目前坚持按照clodal在这篇文章中提出的指示
我有一个包含以下依赖项的package.json:
"@fortawesome/fontawesome-svg-core": "^1.2.8",
"@fortawesome/pro-light-svg-icons": "^5.5.0",
"@fortawesome/free-solid-svg-icons": "^5.5.0",
"@fortawesome/pro-regular-svg-icons": "^5.5.0",
"@fortawesome/pro-solid-svg-icons": "^5.5.0",
"@fortawesome/react-fontawesome": "^0.1.3",
Run Code Online (Sandbox Code Playgroud)
我看过这篇文章并注意到其他人正在努力弄清楚如何开始使用字体真棒.
我已将全局配置身份验证令牌添加到我的应用程序.
我在这里阅读了升级说明.
目前 - 我收到的错误是:
Error: Can't resolve '@fortawesome/pro-brands-svg-icons' in '/Users/18/src/routes/How/components/HowPage'
Run Code Online (Sandbox Code Playgroud)
在那个页面中,我有:
import React from 'react'
import PropTypes from 'prop-types'
import classes from './HowPage.scss'
import GridContainer from "components/Grid/GridContainer.jsx";
import GridItem from "components/Grid/GridItem.jsx";
import Clearfix from "components/Clearfix/Clearfix.jsx";
import { library } from '@fortawesome/fontawesome-svg-core'
import { fas } from '@fortawesome/pro-solid-svg-icons'
import { faTwitter } from …Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的react应用程序中使用一个options数组,该数组使用react-select的形式以及选项存储在firebase集合中的位置。
当我使用带有键值对定义的选项数组来定义表单中的const时,所有这些都很好用,但是我正在努力找出如何用Firebase(Cloud Firestore)中存储的集合替换该数组。
在我的表单中,我目前有:
const options = [
{ value: "neurosciences", label: "Neurosciences - ABS 1109" },
{ value: "oncologyCarcinogenesis", label: "Oncology and Carcinogenesis - ABS 1112" },
{ value: "opticalPhysics", label: "Optical Physics - ABS 0205" },
{ value: "fisheriesSciences", label: "Fisheries Sciences - ABS 0704" },
{ value: "genetics", label: "Genetics - ABS 0604" },
{ value: "urbanRegionalPlanning", label: "Urban and Regional Planning - ABS 1205" }
];
Run Code Online (Sandbox Code Playgroud)
我想用数据库集合中文档标题的映射来替换此数组。
我数据库中的文档名称具有键,每个文档都有一个名为“ title”的字段。
在我的表单中,感谢我选择:
<div className="form-group">
<label htmlFor="fieldOfResearch">
Select your …Run Code Online (Sandbox Code Playgroud) 我正在尝试以Formik形式使用react-datepicker。
我有:
import DatePicker from "react-datepicker";
import "react-datepicker/dist/react-datepicker.css";
class Fuate extends React.Component {
state = {
dueDate: new Date()
}
<Formik
initialValues={initialValues}
validationSchema={Yup.object().shape({
title: Yup.string().required("A title is required "),
})}
onSubmit={this.handleSubmit}
render={({
errors,
status,
touched,
setFieldValue,
setFieldTouched,
handleChange,
handleBlur,
handleSubmit,
isSubmitting,
dirty,
values
}) => {
return (
<div>
...
<DatePicker
name={'dueDate'}
value={values['dueDate']}
onChange={e => setFieldValue('dueDate', e)}
/>
<DatePicker
style={{ width: 180 }}
date={values.dueDate}
mode="date"
format="YYYY-MM-DD"
minDate={Date.now.toString()}
maxDate="2050-06-01"
confirmBtnText="Confirm"
cancelBtnText="Cancel"
showIcon={false}
customStyles={{
dateInput: {
marginLeft: 0,
borderColor: "#fff"
}
}} …Run Code Online (Sandbox Code Playgroud) 我正在尝试弄清楚如何在 antd 前端使用 react-hook-form。
我制作了这个表格,它似乎可以工作(它是多部分表格向导的第 1 部分),只是不显示错误消息。
谁能看到我在合并这两个表单系统时做错了什么?
我没有收到任何错误,但我想我已经要求两个表单字段都是必需的,但是如果我在没有完成它们的情况下按提交,则不会显示错误消息。
import React from "react";
import useForm from "react-hook-form";
import { BrowserRouter as Router, Route } from "react-router-dom";
import { StateMachineProvider, createStore } from "little-state-machine";
import { withRouter } from "react-router-dom";
import { useStateMachine } from "little-state-machine";
import updateAction from "./updateAction";
import { Button, Form, Input, Divider, Layout, Typography, Skeleton, Switch, Card, Icon, Avatar } from 'antd';
const { Content } = Layout
const { Text, Paragraph } = Typography;
const { …Run Code Online (Sandbox Code Playgroud) reactjs ×5
firebase ×3
antd ×1
arrays ×1
devise ×1
font-awesome ×1
formik ×1
glyphicons ×1
omniauth ×1
react-hooks ×1
react-select ×1
roles ×1
rolify ×1
ruby ×1
user-roles ×1
views ×1