我在Rails 2.3.3上,我需要创建一个发送帖子请求的链接.
我有一个看起来像这样的:
= link_to('Resend Email',
{:controller => 'account', :action => 'resend_confirm_email'},
{:method => :post} )
Run Code Online (Sandbox Code Playgroud)
这会在链接上产生适当的JavaScript行为:
<a href="/account/resend_confirm_email"
onclick="var f = document.createElement('form');
f.style.display = 'none';
this.parentNode.appendChild(f);
f.method = 'POST';
f.action = this.href;
var s = document.createElement('input');
s.setAttribute('type', 'hidden');
s.setAttribute('name', 'authenticity_token');
s.setAttribute('value', 'EL9GYgLL6kdT/eIAzBritmB2OVZEXGRytPv3lcCdGhs=');
f.appendChild(s);
f.submit();
return false;">Resend Email</a>'
Run Code Online (Sandbox Code Playgroud)
我的控制器操作正在运行,并设置为不渲染:
respond_to do |format|
format.all { render :nothing => true, :status => 200 }
end
Run Code Online (Sandbox Code Playgroud)
但是当我点击链接时,我的浏览器会下载一个名为"resend_confirm_email"的空文本文件.
是什么赋予了?
我有两张桌子:items和orders
items
--------------
id (int) | type_1 (int) | type_2 (int)|
orders
--------------
id (int) | transaction_type enum ('type_1', 'type_2')
Run Code Online (Sandbox Code Playgroud)
基本上,我想做以下事情:
select (select transaction_type from orders where id=1) from items;
Run Code Online (Sandbox Code Playgroud)
所以,问题是string返回的select transaction_type from orders where id=1,不能转换成列名.
我正在尝试使用 yup 概念实现对 react-select(单选)的验证。但我收到此错误:
对象作为 React 子对象无效(找到:带有键 {label, value} 的对象)。如果您打算渲染一组子项,请改用数组。
我想知道如何在验证模式中为 yup 概念分配对象
<Formik
initialValues={{
department:"",
}}
onSubmit={this.submitForm}
validationSchema={Yup.object().shape({
department: Yup.object().shape({
label: Yup.string().required(),
value: Yup.string().required(),
}),
})}>
{ props => {
const {
values,
touched,
errors,
isSubmitting,
handleChange,
handleBlur,
handleSubmit,
selectedOption
} = props;
return (
<React.Fragment>
<InputLabel shrink htmlFor={'department'}>
Department</InputLabel>
<Select
inputId="department"
options={options}
value={values.department}
onChange={this.onChangeOption}
onBlur={handleBlur}
/>
{errors.department && touched.department && ( {errors.department} )}
Submit </div> </React.Fragment> ); }}
Run Code Online (Sandbox Code Playgroud) 我正在使用react-native-fbsdk: 0.8.0, react-native-firebase: ^5.2.2, react-native: ^0.57.4Facebook 测试用户帐户。
这发生的太突然了。一旦我从 firebase 注销并尝试使用 Facebook 再次登录。
错误:提供的身份验证凭据格式错误或已过期。[来自 facebook.com 的 USER_INFO 远程站点 5XX]。
我试过 AccessToken.refreshCurrentAccessTokenAsync()。但是给我错误:无法刷新访问令牌。
Facebook 令牌将在 60 天后过期。查了一下token过期日期是2019年4月29日,修改test用户账号密码,重新登录,还是一样。
在 facebook 或 firebase 设置中有什么我需要做的吗?
const result = await LoginManager.logInWithReadPermissions(["public_profile","email"]);
if (result.isCancelled) {
this.setState({isLoading : false});
Alert.alert('Error','Login cancelled. Please try again');
} else {
try{
await AccessToken.refreshCurrentAccessTokenAsync();
}catch(err){
this.setState({isLoading : false});
console.log('ereee',err);
}
const data = await AccessToken.getCurrentAccessToken();
var credential = firebase.auth.FacebookAuthProvider.credential(data.accessToken);
console.log(data.accessToken);
//here I get expired date is 2019 April 29
console.log(moment(data.expirationTime).toDate());
firebase.auth().signInWithCredential(credential) …Run Code Online (Sandbox Code Playgroud) 目前我正在尝试在 Rails 6 中显示.HEIC图像。我正在使用ActiveStorage ImageMagic来使用变体来显示jpg. 基本上我正在尝试使用
mogrify -format jpg myimage.heic
Run Code Online (Sandbox Code Playgroud)
在图像中进行显示jpg。
我添加Rails.application.config.active_storage.variant_processor到 application.rb 中以便能够使用该变体。然而,它似乎打破了以下行:
<%= image_tag post.image.variant(format: 'jpg'), class: "card-home__img" %>
Run Code Online (Sandbox Code Playgroud)
为什么不工作?
ruby-on-rails imagemagick rails-activestorage ruby-on-rails-6
我有一个简单的 HTML 表单,我正在使用 Fetch API 和 FormData 向我的服务器发送一些数据。
我要送role,并user_id与他们的价值观到服务器。在控制器中打印时params我得到:
{"-----------------------------1190833731009709688837505639\r\nContent-Disposition: form-data; name"=>"\"角色\"\r\n\r\nadmin\r\n----------------------------1190833731009709688837505639\r\n内容-处置:form-data; name=\"user_id\"\r\n\r\n1\r\n------------------------ ----1190833731009709688837505639--\r\n", "controller"=>"users", "action"=>"updaterole", "id"=>"1"}
如何访问和获取role和user_id值从这个?
这是我在客户端的脚本:
var form = document.querySelector("#roleForm");
var formdata = new FormData(form);
fetch(url, {
method: "PATCH",
headers: { 'Content-Type':'multipart/form-data' },
body: formdata,
}).then(
response => response.text() // .json(), etc.
// same as function(response) {return response.text();}
).then(
html => {
console.log(html)
}
);
Run Code Online (Sandbox Code Playgroud) 将 Rails 5.2 项目升级到 Rails 6。升级后,当我尝试拉起站点时,出现以下错误:
Can't resolve image into URL: undefined method `start_with?' for /\.(?:svg|eot|woff|ttf)$/:Regexp
Run Code Online (Sandbox Code Playgroud)
这是代码:
def source_image(source)
if source == 'blah'
return image_tag 'blah.png', size: '18', :title => 'blah', :data => {:toggle => 'tooltip', :placement => 'right', }
end
end
Run Code Online (Sandbox Code Playgroud) 我在 AWS EKS 上的 kubernetes 集群的帮助下运行我的 docker 容器。我的两个 docker 容器正在使用共享卷,并且这两个容器都在两个不同的 pod 中运行。所以我想要一个可以被 aws 上的两个 Pod 使用的公共卷。
我创建了一个 EFS 卷并安装。我正在按照链接创建PersistentVolumeClaim. 但是当efs-providerpod 尝试附加已安装的 EFS 卷空间时出现超时错误。VolumeId,区域仅正确。
Pod 的详细错误消息描述:
等待卷为 pod“default”/“efs-provisioner-55dcf9f58d-r547q”附加或挂载的超时超时。卸载卷列表=[pv-volume]。未附加卷列表=[pv-volume default-token-lccdw]
MountVolume.SetUp 卷“pv-volume”失败:挂载失败:退出状态 32
当我单独运行时,我有以下测试通过:
require 'rails_helper'
RSpec.describe 'deleting a non-recurring user event', js: true do
let(:user) { create(:proofreader_user) }
let(:date) { Date.current.strftime('%Y-%m-%d') }
let(:date_time) { date + ' 00:00'}
it 'deletes the event' do
visit root_path
click_on "Login"
fill_in "Email", with: user.email
fill_in "Password", with: user.password
click_on "Sign In"
visit calendar_path
expect(current_path).to eq(calendar_path)
expect(page).to have_css("#complete_registration:disabled")
expect(page).to_not have_css("td.fc-event-container")
find("td.fc-day[data-date='#{date}']").click
expect(page).to have_css("div#user-event-modal")
expect(page).to have_select('user_event[title]', :options => UserEvent.titles.keys)
expect(find('input', id: 'user_event_starting').value).to eq date_time
expect(find('input', id: 'user_event_ending').value).to eq date_time
page.execute_script("$('input#user_event_starting').val('#{date} 09:00')")
expect(find('input', id: 'user_event_starting').value).to eq date + …Run Code Online (Sandbox Code Playgroud) 我已经通读了我可以在这里找到的所有评论和问题,但它们似乎都不适用于我的情况。我有一个 Ruby on Rails 后端,React 前端部署良好,直到我添加了管理员使用 ActiveRecord 通过 CSV 文件更新数据库的能力。
当我推送到 Heroku 时,我现在收到两个警告:
###### 警告:检测 rails 配置失败
##### 警告:我们检测到此系统上不存在使用 Active Storage 的所有预览功能所需的某些二进制依赖项。
我已经阅读了 Heroku 提供的有关 Heroku 上主动存储的文章,但我仍然无法解决问题。
尝试在 Rails 控制台上进行故障排除时,我收到以下可能是罪魁祸首的错误:
/app/vendor/bundle/ruby/2.5.0/gems/aws-partitions-1.144.0/lib/aws-partitions/endpoint_provider.rb:82:in partition_matching_region 中的块:无法加载 Rails.config.active_storage.service: (NoMethodError) nil:NilClass 的未定义方法匹配
有没有人对这个问题有任何见解?我遇到了其他人发现的相同内容:其中一些错误消息对我来说并不是最有见地的。谢谢!
amazon-ec2 ×1
amazon-efs ×1
docker ×1
formik ×1
heroku ×1
imagemagick ×1
kubernetes ×1
link-to ×1
mysql ×1
react-native ×1
react-select ×1
reactjs ×1
rest ×1
rspec-rails ×1
ruby ×1
yup ×1