我正在使用react-navigation并且有一个带有 ParentScreen和ChildScreen的StackNavigator.
两个屏幕都具有相同的导航栏,其动态值来自redux.像问题#313中描述的那样实现
这按预期工作.当我在DetailScreen中并更新count变量的值时,它还会更新导航栏中的值.
问题是,如果我回到父场景,导航栏中仍然存在旧值.它不会更新到redux存储中的当前值.
儿童

家长(当我回去时)

ChildScreen
class ChildScreen extends Component {
static navigationOptions = {
title: ({ state }) => `Total: ${state.params && state.params.count ? state.params.count : ''}`
};
componentWillReceiveProps(nextProps) {
if (nextProps.count != this.props.count) {
this.props.navigation.setParams({ count: nextProps.count });
}
}
render() {
return (
<View>
<Button onPress={() => this.props.increment()} title="Increment" />
</View>
);
}
}
Run Code Online (Sandbox Code Playgroud)
ParentScreen
class ParentScreen extends Component {
static navigationOptions = {
title: ({ state …Run Code Online (Sandbox Code Playgroud) 我试图在railscasts教程的帮助下配置我的paypal网关和activemerchant,但我有点困惑,因为网关信息已经改变.
这是教程中的旧配置:
gateway = ActiveMerchant::Billing::PaypalGateway.new(
login: "...",
password: "...",
signature: "..."
)
Run Code Online (Sandbox Code Playgroud)
在我的PaypalSandbox帐户中我只有这个:
什么是正确的配置?
我用Carrierwave和Fog将我的图像上传到S3.在上传时,我还创建了图像的缩略图版本:
version :thumb do
process :resize_to_limit => [90, 80], if: :is_resizable?
end
Run Code Online (Sandbox Code Playgroud)
现在我需要一种方法来检查缩略图版本是否存在.
该文件列出了exists?方法.这实际上有效,如果我想检查原始版本的存在:
asset.file.exists? # => true
Run Code Online (Sandbox Code Playgroud)
但是当我使用像这样的"拇指"版本时:
asset.url(:thumb).file.exists?
Run Code Online (Sandbox Code Playgroud)
它得到:
undefined method 'exists?' for #<String:0x007fcd9f9d9620>:
就像本教程中描述的那样,我将画布转换为DataUrl,将此DataUrl转换为Blob.然后我发出一个ajax post请求,并希望使用Carrierwave将图像保存在数据库中.
这是我的JS代码:
uploadButton.on('click', function(e) {
var dataURL = mycanvas.toDataURL("image/png;base64;");
// Get our file
var file= dataURLtoBlob(dataURL);
// Create new form data
var fd = new FormData();
// Append our Canvas image file to the form data
fd.append("image", file);
// And send it
$.ajax({
url: "/steps",
type: "POST",
data: fd,
processData: false,
contentType: false,
});
});
// Convert dataURL to Blob object
function dataURLtoBlob(dataURL) {
// Decode the dataURL
var binary = atob(dataURL.split(',')[1]);
// Create 8-bit unsigned array …Run Code Online (Sandbox Code Playgroud) Twitter Bootstrap具有表单的此角色属性:
<form role="form">
Run Code Online (Sandbox Code Playgroud)
如何在Rails表单助手中包含角色属性?我试过这个,但它不起作用:
<%= form_for @user, class: "form-horizontal", role: "form" do |f| %>
Run Code Online (Sandbox Code Playgroud) 我的设置:Ubuntu 12.04 LTS,Apache,Phusion Passenger,最新的Ruby和Rails.
当我访问我的网站时,我收到500内部服务器错误.错误日志文件:脚本标头的过早结束
有人知道如何解决这个问题吗?
我已经安装了rails.vim,它似乎在:Rails!返回后正确安装rails.vim 5.0.
但是,如果我在现有的Rails项目中并查找:Rfind user我得到的文件E492: Not an editor command: Rfind user.
有什么建议?
我正在研究是否可以使用React Native轻松实现,或者我是否应该构建本机应用程序.
我想编辑照片库中的图像并为其添加文本叠加层.可以把它想象成带有问候语的明信片.
我如何添加文本和图像并在本机中生成它的新副本?我不是在寻找详细的代码,只是为了解释如何开始.
更新: 它是一个很好的替代方案,只是保存图片上的消息坐标而不是生成新的图像?
我通过代理发送一个http请求,需要在我的请求中添加用户名和密码。如何正确将这些值添加到我的选项块?
这是我的代码:
var http = require('http');
var options = {
port: 8080,
host: 'my.proxy.net',
path: '/index',
headers: {
Host: "http://example.com"
}
};
http.get(options, function(res) {
console.log("StatusCode: " + res.statusCode + " Message: " + res.statusMessage);
});
Run Code Online (Sandbox Code Playgroud)
当前,响应为StatusCode:307,消息:Authentication Required。
我试图将用户名和密码添加到我的选项中,但是它不起作用:
var options = {
port: 8080,
host: 'my.proxy.net',
username: 'myusername',
password: 'mypassword',
path: '/index',
headers: {
Host: "http://example.com"
}
};
Run Code Online (Sandbox Code Playgroud)
附加信息: 我没有太多有关代理的信息,但在另一种情况下,此身份验证方法有效:
npm config set proxy http://username:password@my.proxy.net:8080
Run Code Online (Sandbox Code Playgroud) 为了解决我的问题,在" 生产未定义方法'paginate'中的" will_paginate错误 "中讨论过,我尝试运行:
script/rails runner -e production
Run Code Online (Sandbox Code Playgroud)
和:
bundle exec script/rails runner -e production
Run Code Online (Sandbox Code Playgroud)
在服务器上像这个github问题中建议的那样:https://github.com/mislav/will_paginate/issues/308#issuecomment-17167158
但是我收到以下错误:
bundler: command not found: script/rails
Install missing gem executables with `bundle install`
Run Code Online (Sandbox Code Playgroud)
捆绑安装没有帮助.有什么建议?
我正在使用:Ruby 2.0.0p247,Rails 4.0.0,Ubuntu 12.10 LTS,Unicorn,Capistrano
我在我的服务器上设置了两个Rails4-Apps,Capistrano 2.15,Unicorn和Nginx.
当我这样做时cap:deploy,我收到此错误:
executing "/etc/init.d/unicorn_myapp1 restart"
servers: ["123.45.678.910"]
[123.45.678.910] executing command
** [out :: 123.45.678.910] Couldn't reload, starting 'cd/home/deployer/apps/myapp1/current; bundle exec unicorn -D -c /home/deployer/apps/myapp1/current/config/unicorn.rb -E production' instead
** [out :: 123.45.678.910]
** [out :: 123.45.678.910] master failed to start, check stderr log for details
command finished in 1845ms
failed: "rvm_path=$HOME/.rvm $HOME/.rvm/bin/rvm-shell 'ruby-2.0.0-p353' -c '/etc/init.d/unicorn_myapp1 restart'" on 123.45.678.910
Run Code Online (Sandbox Code Playgroud)
更多信息:
如果我在服务器上手动终止工作程序,则部署过程可以正常工作(但仍会显示重新启动错误).
我怀疑,这个错误与事实有关,我正在同时运行2个应用程序.如果我只运行一个应用程序就行了.
finalize_update步骤输出:
* 2014-01-13 13:31:11 executing `deploy:finalize_update'
triggering before callbacks for `deploy:finalize_update'
* 2014-01-13 …Run Code Online (Sandbox Code Playgroud) 在我的routes.rb 中,我想将 root_path 设置为 '/' 而不指定任何控制器或操作。那可能吗?
我试过了,root to: '/'但它在抱怨,没有指定控制器或操作。
更新信息:
我正在使用comfort-mexican-sofa CMS,我的root_path 应该转到cms 根路径。
目前我只是redirect_to '/'在我的控制器中使用并且这是有效的,但我认为使用root_path.
routes ruby-on-rails ruby-on-rails-4 comfortable-mexican-sofa
我想在ERB中写这个HTML:
<a href="/" id="logo">One<span id="red>Two</span></a>
Run Code Online (Sandbox Code Playgroud)
如何包含跨度?
<%= link_to "ONETWO", root_path, id: "logo" %>
Run Code Online (Sandbox Code Playgroud) ruby-on-rails ×10
ruby ×3
carrierwave ×2
javascript ×2
react-native ×2
unicorn ×2
amazon-s3 ×1
android ×1
apache ×1
base64 ×1
blob ×1
capistrano ×1
data-uri ×1
erb ×1
fog ×1
form-helpers ×1
forms ×1
html ×1
http ×1
ios ×1
nginx ×1
node.js ×1
passenger ×1
paypal ×1
proxy ×1
rails.vim ×1
reactjs ×1
role ×1
routes ×1
ubuntu-12.04 ×1
vim ×1