我正在尝试在 Next.js 中使用锚标记
我设置后点击链接没有出现任何控制台错误,但是页面没有跳转到id标签。
github 上的这个问题表明人们需要找出大量自定义代码才能使用锚点。那是不对的。
我有:
const links = [
{ label: 'Solutions', href: '#solutions', id: 'solutions' },
]
<NavLink.Desktop key={index} href={link.href} id={link.id}>
{link.label}
</NavLink.Desktop>
Run Code Online (Sandbox Code Playgroud)
我没有收到任何错误,但页面没有跳转到 id 为“solutions”的标签。
有谁知道如何解决这个问题,或者去哪里寻找解决方法的想法 - 不可能需要复杂的自定义代码来使用锚标记?
我正在尝试使用我的rails 4应用程序的简单表单.
我有一个项目模型,它有一个范围模型.范围属于项目.我有第三个模型,称为参与者,属于范围.Scope接受参与者的嵌套属性,项目接受范围的嵌套属性.
当我创建一个新项目时,我的表单有部分内容,这些部分是每个范围和参与者的嵌套表单.在我的范围表格中,我问这个项目是否涉及参与者.如果答案是真的,我使用JS表单助手来显示包含参与者表单的隐藏部分.
如果在创建项目后,我想编辑它,编辑功能会将我返回到项目表单,该表单显示参与者的复选框(如为true),但隐藏参与者表单.
我的问题是,如果选中参与者复选框为true,则应显示嵌套在项目表单中的参与者表单.我的JS表单助手隐藏了这个表单,直到选中该框为真,这在创建模式下工作正常,但我需要取消检查范围表单中的参与者框并重新检查它以显示参与者表单 - 这样我就可以编辑这些字段了.
如果在没有取消选中并重新检查表单的情况下询问参与的范围问题是真的,您知道如何透露参与者表格吗?
我的代码如下:
在我的JS表单助手中,我有(隐藏参与者嵌套表单,除非询问是否参与的范围问题是真的):
$(document).on 'change', '#' + inString + '_scope_attributes_if_participant', ()->
if $('#' + inString + '_scope_attributes_if_participant').is(':checked')
$('#participationrequest').show()
else
$('#participationrequest').hide()
Run Code Online (Sandbox Code Playgroud)
在我的范围表格中,我有:
<%= s_all.input :if_participant, :as => :boolean, :label => false, inline_label: 'Public participants or volunteers' %>
Run Code Online (Sandbox Code Playgroud)
谢谢
我正在尝试在Rails 4中创建一个应用程序.我已经尝试了最近3年(除了10天),以便设计工作.
我正在尝试按照本教程:http://sourcey.com/rails-4-omniauth-using-devise-with-twitter-facebook-and-linkedin/
请不要推荐其他教程/ gem文档.我已经尝试了至少30个其他教程,并且gem文档中充满了我不理解的错误和组件.
我目前的问题是,当我到达本教程中的完成注册步骤时,表单会询问我的电子邮件地址.
用户控制器具有完成注册方法:
def finish_signup
# authorize! :update, @user
if request.patch? && params[:user] #&& params[:user][:email]
if @user.update(user_params)
@user.skip_reconfirmation!
# sign_in(@user, :bypass => true)
# redirect_to root_path, notice: 'Your profile was successfully updated.'
# redirect_to [@user, @user.profile || @user.build_profile]
sign_in_and_redirect(@user, :bypass => true)
else
@show_errors = true
end
end
end
Run Code Online (Sandbox Code Playgroud)
当我尝试这个时,我收到此错误:
undefined method `match' for {:host=>"localhost", :port=>3000}:Hash
Run Code Online (Sandbox Code Playgroud)
此行的错误点:
<div class="intpol3"><%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %></div>
Run Code Online (Sandbox Code Playgroud)
我的开发环境设置为包含电子邮件发件人的所有配置详细信息.
当我在生产模式中尝试相同的步骤时,我收到此错误:
ActionView::Template::Error (No route matches …Run Code Online (Sandbox Code Playgroud) 我正在尝试在Rails 4中制作应用程序.
在过去的3年里,我一直在努力弄清楚设计/ omniauth(我仍然试图让它发挥作用).
在我试图找到通过这个问题的意愿时,除了主要问题之外,我已经尝试使用Mandrill设置电子邮件.
我找到了这个教程,我试图遵循这个教程:https://nvisium.com/blog/2014/10/08/mandrill-devise-and-mailchimp-templates/
我有一个叫做mandrill_devise_mailer.rb的邮件程序
class MandrillDeviseMailer < Devise::Mailer
def confirmation_instructions(record, token, opts={})
# code to be added here later
end
def reset_password_instructions(record, token, opts={})
options = {
:subject => "Reset your password",
:email => record.email,
:global_merge_vars => [
{
name: "password_reset_link",
# content: "http://www.example.com/users/password/edit?reset_password_token=#{token}"
content: "http://www.cr.com/users/password/edit?reset_password_token=#{token}"
},
{
name: "PASSWORD_RESET_REQUEST_FROM",
content: record.full_name
}
],
:template => "Forgot Password"
}
mandrill_send options
end
def unlock_instructions(record, token, opts={})
# code to be added here later
end …Run Code Online (Sandbox Code Playgroud) 我正在尝试将Evaluation模型添加到我的Rails 4应用中.
我做了一个名为的模型evaluation.rb.它有:
class Evaluation < ActiveRecord::Base
belongs_to :evaluator, :polymorphic => true
belongs_to :evaluatable, :polymorphic => true
Run Code Online (Sandbox Code Playgroud)
我也提出了担忧evaluator,并evaluatable为:
module Evaluator
extend ActiveSupport::Concern
included do
has_many :given_evaluations, as: :evaluator, dependent: :destroy, class_name: 'Evaluation'
end
end
module Evaluatable
extend ActiveSupport::Concern
included do
has_many :received_evaluations, as: :evaluatable, dependent: :destroy, class_name: 'Evaluation'
end
end
Run Code Online (Sandbox Code Playgroud)
我在用户模型中包含了每个问题:
class User < ActiveRecord::Base
include Evaluator
include Evaluatable
Run Code Online (Sandbox Code Playgroud)
在我的展示页面中,我想展示特定用户的评估(从其他用户 - 他们是评估者)收到.
在我的节目中,我有:
<% Evaluation.find(params[:id]).evaluations.order('created_at DESC').each do |eval| %>
<div …Run Code Online (Sandbox Code Playgroud) 我正试图弄清楚如何在我的Rails 4应用程序中使用dependent-fields-rails gem.
我迷路了.
我在我的供应商javascripts文件夹中包含了underscore.js并更新了我的application.js以包含(在底部,正上方需要树):
//= require underscore
//= require dependent-fields
$(document).ready(function() {
DependentFields.bind()
});
Run Code Online (Sandbox Code Playgroud)
以我简单的形式,我有:
<%= f.input :has_milestones, as: :boolean, boolean_style: :inline, :label => 'Any decision points?', id: 'check_project_milestones' %>
<%= content_tag :div, class: 'js-dependent-fields', data: {'checkbox-id': 'check_project_milestones', 'checkbox-value': 'true' } do %>
<div class="intpol2">
Milestones
</div>
<%= f.simple_fields_for :milestones do |f| %>
<%= render 'milestones/milestone_fields', f: f %>
<% end %>
<% end %>
Run Code Online (Sandbox Code Playgroud)
但是,当我重新启动服务器并呈现表单时,会显示第一个具有div id的问题(未选中复选框),并且内容标记内的内容也会显示.我希望它被隐藏,直到选中复选框.
我在driftingruby.com上找到了一个教程,展示了如何进行设置.我唯一可以猜到的是,可能需要使用turbo链接才能完成这项工作?我禁用它因为我使用olark.
当我检查控制台是否有错误时,我可以看到这个,这似乎是相关的:
[Error] Failed to load resource: the server responded with a …Run Code Online (Sandbox Code Playgroud) 我试图学习如何在Rails 5中编写范围.
我有一个用户模型和一个提案模型.协会是:
用户:
has_many :proposals
Run Code Online (Sandbox Code Playgroud)
提案:
belongs_to :user
Run Code Online (Sandbox Code Playgroud)
在我的提案模型中,我试图弄清楚如何编写一个范围来查找属于创建它们的用户的提案.
我在尝试:
scope :proponent, -> { where(user_id: user.id) }
Run Code Online (Sandbox Code Playgroud)
我已经尝试了一百万种变体,但我找不到一种有效的.
此特定尝试会出现此错误:
2.3.1p112 :001 > Proposal.proponent
NameError: undefined local variable or method `user' for Proposal (call 'Proposal.connection' to establish a connection):Class
Run Code Online (Sandbox Code Playgroud)
我也尝试过:
scope :proponent, -> { where('proposal.user_id = ?', user.id) }
Run Code Online (Sandbox Code Playgroud)
我从这次尝试中得到的错误是:
undefined local variable or method `user' for #<Class:0x007fd3600eb038>
Run Code Online (Sandbox Code Playgroud)
我不知道错误消息是否意味着我在尝试中第一次或第二次写"用户"是不正确的.我不知道"叫什么'Proposal.connection'的意思是".
任何人都可以看到我需要做什么才能检查提案表以找到属于特定用户的提议表?
我正在尝试登录我的heroku帐户.
我不断收到一条错误消息"您的登录信息存在问题".没有详细说明问题所在.
我尝试通过忘记密码操作更改我的密码,我仍然被定向回到上面的错误消息.
我无法联系Heroku的支持团队,因为我无法登录.
有没有人发现这个问题并找到了解决方法 - 甚至是联系Heroku的方法?
我正在尝试向我的Formik表单添加一个react-bootstrap警报,以便handleSubmit包括一个警告用户该表单已提交。
我已经使用了react-bootstrap记录的Alert形式,但是我不得不更改最后一行,因为这似乎不起作用(该错误表明如果我使用react-bootstrap记录的Alert形式,则没有导出任何内容。
我的警报是:
import React from 'react';
import {
Alert,
Button,
} from "react-bootstrap";
class AlertDismissible extends React.Component {
constructor(props) {
super(props);
this.state = { show: true };
}
render() {
const handleHide = () => this.setState({ show: false });
const handleShow = () => this.setState({ show: true });
return (
<>
<Alert show={this.state.show} variant="light">
<Alert.Heading>Thanks for your interest </Alert.Heading>
<p>
We'll be in touch with login details shortly.
</p>
<hr />
<div className="d-flex justify-content-end">
<Button onClick={handleHide} variant="outline-success">
Close
</Button> …Run Code Online (Sandbox Code Playgroud) 我正在尝试学习如何将 prisma 与 psql 数据库一起使用。
我在使用 id 是 uuid 字符串的引用时遇到了问题。
我有一个用户模型:
model User {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
request Request?
createdAt DateTime @default(now()) @db.Timestamptz(6)
updatedAt DateTime @default(now()) @updatedAt @db.Timestamptz(6)
}
model Request {
id Int @id @default(autoincrement())
user User @relation(fields: [id], references: [id])
// I also tried making the relation field userId
createdAt DateTime @default(now()) @db.Timestamptz(6)
updatedAt DateTime @default(now()) @updatedAt @db.Timestamptz(6)
}
Run Code Online (Sandbox Code Playgroud)
当我尝试迁移它时,我收到一条错误消息:
无法干净地应用到影子数据库。错误:数据库错误:错误:无法实现外键约束“Request_userId_fkey”详细信息:键列“userId”和“id”的类型不兼容:文本和uuid。
prisma 文档没有显示使用 uuid 的示例。
他们给出的示例在 Profile 模型中有第二个参数,其中 userId 作为 Int。我尝试将其添加到我的请求模型中(作为 int、作为字符串和作为 uuid)。这些都不起作用。
model User { …Run Code Online (Sandbox Code Playgroud) javascript ×3
devise ×2
actionmailer ×1
email ×1
formik ×1
heroku ×1
html ×1
jquery ×1
mandrill ×1
next.js ×1
omniauth ×1
polymorphism ×1
prisma ×1
psql ×1
reactjs ×1
ruby ×1
scope ×1
simple-form ×1