我想在所有屏幕中全局显示HeaderLeft菜单图标。当我单击菜单图标时,我需要显示抽屉菜单。我使用“ OpenDrawer”,“ CloseDrawer”方法打开/关闭抽屉菜单。
但是我总是在“ undefined is not a function (evaluating 'props.navigation.openDrawer()')"。我也尝试了以下
props.navigation.dispatch(DrawerActions.openDrawer())
props.navigation.navigate(openDrawer())
Run Code Online (Sandbox Code Playgroud)
但以上方法均无效。这是我的部分代码
const MenuButton = (props) => {
return (
<View>
<TouchableOpacity onPress={() => { props.navigation.dispatch(DrawerActions.openDrawer())} }>
<Text>Menu</Text>
</TouchableOpacity>
</View>
)
};
const MyDrawerNavigator = createDrawerNavigator(
{
Wishist: {
screen: wishlist
},
},
{
contentComponent: SideMenuScreen,
drawerWidth: 200,
}
);
const AppNavigator = createBottomTabNavigator({
Home: {
screen: createStackNavigator({
Home: {
screen: Home
},
Contact: {
screen: Contact
}
},
{
defaultNavigationOptions: ({ navigation }) => ({
headerStyle: …Run Code Online (Sandbox Code Playgroud) 非常感谢你的帮助。我有一个locations和ads表。地点has_many :ads
我想Location使用joinwith AdModel查询Model,以过滤Location和参数的条目Ad。
@locations = Location.joins(:ads).where(locations: location_params, ads: location_params[:ads_attributes])
Run Code Online (Sandbox Code Playgroud)
这是 location_params 方法(将使用另一种工作正常的方法删除空字段)。
params.require(:location).permit(:country, {:ads_attributes => [:remote, :days]})
Run Code Online (Sandbox Code Playgroud)
这是我的查询的一个例子。我有一个方法可以从 location_params 中删除空字段。它工作正常。
SELECT "locations".* FROM "locations" INNER JOIN "ads"
ON "ads"."location_id" = "locations"."id"
WHERE "ads_attributes"."remote" = $1 [["remote", "1"]]
Run Code Online (Sandbox Code Playgroud)
在这种情况下,location_params 具有以下字段:
<ActionController::Parameters {"ads_attributes"=>
<ActionController::Parameters {"remote"=>"1"} permitted: true>} permitted: true>
Run Code Online (Sandbox Code Playgroud)
这是结果,一个空对象,即使我的表中有包含这些参数的条目
#<Location::ActiveRecord_Relation:0x3fb83def8190>
Run Code Online (Sandbox Code Playgroud)
解决方案。使用.includes(:ads)不重新执行与查询@locations[0].ads。
@locations = Location.joins(:ads).where(locations: …Run Code Online (Sandbox Code Playgroud) 我正在使用基于Ubunt 17.04的Linux 18.当我跑步时,rails assets:precompile我得到以下消息Yarn executable was not detected in the system
当我按照本帖子或网页上的安装说明进行操作时,我成功安装了Yarn,但rails一直给我错误
我注意到node.js有Linux Mint的系统包到版本17.2,我试图对Yarn页面执行所有指令并手动安装node.js已安装在我的系统中.
该消息并不能解释问题.如果我运行yarn --help它是有效的,我的yarn --version是0.22
这是我的Linux Mint系统
DISTRIB_ID=LinuxMint
DISTRIB_RELEASE=18
DISTRIB_CODENAME=sarah
DISTRIB_DESCRIPTION="Linux Mint 18 Sarah"
NAME="Ubuntu"
VERSION="16.04 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
UBUNTU_CODENAME=xenial
cat: /etc/upstream-release: Is a directory
Run Code Online (Sandbox Code Playgroud)
更新
这是我$PATH在终端中回显的输出/opt/yarn-0.22/bin,但当我走到那条路径时,没有文件夹,/opt/yarn-0.22所以我需要了解它的安装位置并正确配置PATH SETUP
Path Setup
If you …Run Code Online (Sandbox Code Playgroud) 作为标题,我使用的是docker ruby 2.3.5(ubuntu)环境,尽管我已经设置了NODE_ENV =开发,当我试图拦截process.env.NODE_ENV我仍然看到生产的值时,我无法找到它已被覆盖的任何地方.它只发生在docker环境中但不在我的MacOS上,不确定是什么原因?
更新:这里是Dockerfile和docker-compose.yml供参考:https://gist.github.com/goodwill/b4e677ccf8fe0079183adeec35218812
更新:这是我在运行webpacker-dev-server时遇到的错误:
04:08:37 webpacker.1 | /app/config/webpack/development.js:20
04:08:37 webpacker.1 | https: settings.dev_server.https,
04:08:37 webpacker.1 | ^
04:08:37 webpacker.1 |
04:08:37 webpacker.1 | TypeError: Cannot read property 'https' of undefined
04:08:37 webpacker.1 | at Object.<anonymous> (/app/config/webpack/development.js:20:31)
04:08:37 webpacker.1 | at Module._compile (module.js:570:32)
04:08:37 webpacker.1 | at Object.Module._extensions..js (module.js:579:10)
04:08:37 webpacker.1 | at Module.load (module.js:487:32)
04:08:37 webpacker.1 | at tryModuleLoad (module.js:446:12)
04:08:37 webpacker.1 | at Function.Module._load (module.js:438:3)
04:08:37 webpacker.1 | at Module.require (module.js:497:17)
04:08:37 webpacker.1 …Run Code Online (Sandbox Code Playgroud) 我需要在 Rails 控制台中执行此操作,按照Rails API ActionView::Helpers::TextHelper中的说明进行操作 我已经在下面的Stackoverflow Discussion中找到了问题的解决方案,但我认为发布该问题可能会很有用。如果你想让我删除它,就告诉我。
ActionView::Helpers::TextHelper我想在我的 Rails 控制台中创建一个
texthelper = ActionView::Helpers::TextHelper
=> ActionView::Helpers::TextHelper
Run Code Online (Sandbox Code Playgroud)我创建一个字符串
string = "I want to call the truncate method"
=> "I want to call the truncate method"
Run Code Online (Sandbox Code Playgroud)我想在我的控制台中对该字符串调用截断方法。
truncate(string, length: 25, omission: '... (continued)')
=> "And they f... (continued)"
Run Code Online (Sandbox Code Playgroud)当我在控制台输入:
truncate("Once upon a time in a world far far away", length: 17, separator: ' ')
Run Code Online (Sandbox Code Playgroud)
我收到
undefined method `truncate' for main:Object
Run Code Online (Sandbox Code Playgroud)
整个想法来自这篇文章.. 模型中未定义的方法“truncate”
我正在阅读CSS规范,有关视觉格式模型的部分,并试图了解这两个术语之间的区别:containing block和block container box。
使我感到困惑的是,似乎完全不同的概念所使用的单词的变化形式:
box 与 block containing 与 container是block一样的box谈论视觉格式化CSS的时候?如果没有,有什么区别?这两种东西都是在屏幕上“可见”的吗?
总的来说,当我block在规范中看到该怎么看?另外,阅读box规格时应该首先想到什么?
这些概念的一些有用的隐喻或类比对创建心理模型非常有帮助。
非常感谢你的建议.我迁移到Heroku,我有facebook omniauth身份验证的以下问题.当我使用facebook进行身份验证时,回调URL不起作用,我会收到https://barteringapps.herokuapp.com/#_=_以下日志错误消息发送到主页:
"redirect_uri isn't an absolute URI. Check RFC 3986.","type":"OAuthException","code":191,"fbtrace_id":"BT1wrRRo64m"
method=GET path="/" host=barteringapps.herokuapp.com request_id=8913218f-703d-4da0-9388-f59d3a97bb69 fwd="81.171.81.200" dyno=web.1 connect=0ms service=11ms status=200 bytes=13425
Run Code Online (Sandbox Code Playgroud)
在开发中,当我在devise.rb和facebook App设置中设置callback-url时,功能可以正常工作http://127.0.0.1:5000/users/auth/facebook/callback
所以给出一个更详细的日志(我省略了不重要的信息):
我点击登录链接
method=GET path="/users/sign_in" host=barteringapps.herokuapp.com fwd="81.171.81.200" status=200
Run Code Online (Sandbox Code Playgroud)我点击登录facebook
method=GET path="/users/auth/facebook" host=barteringapps.herokuapp.com fwd="81.171.81.200" status=302
INFO -- omniauth: (facebook) Request phase initiated.
Run Code Online (Sandbox Code Playgroud)从facebook回调,我注意到该路径不包括我的主机
method=GET path="/users/auth/facebook/callback?code='sometoken'" host=barteringapps.herokuapp.com fwd="81.171.81.200"
Run Code Online (Sandbox Code Playgroud)我已经搜索了Stackoverflow的解决方案,我按照这个说明 设计了omniauth-facebook redirect_uri Url必须绝对
我在devise.rb中配置了这样的绝对路径
callback_url: ENV['SERVER_ROOT']+'/users/auth/facebook/callback' …Run Code Online (Sandbox Code Playgroud)我已经在这行代码上工作了三天。我有以下强大的参数:
def location_params
params.require(:location).permit(:country, {:ads_attributes => [:remote, :days]})
end
Run Code Online (Sandbox Code Playgroud)
方法param_clean将从location_params 中删除空字段,但它不适用于嵌套的:ads_attributes。主要原因是param_clean只能在具有ActiveController::Parameters类的location_params上调用。我不能调用v方法param_clean
def param_clean
location_params.delete_if{ |k, v| v.empty? or v.instance_of?(ActionController::Parameters) && v.param_clean.empty? }
end
Run Code Online (Sandbox Code Playgroud)
我收到以下错误
undefined method `param_clean' for #<ActionController::Parameters:0x007f..>
Run Code Online (Sandbox Code Playgroud)
这是 location_params 的值
<ActionController::Parameters {"country"=>"", "ads_attributes"=><ActionController::Parameters {"remote"=>"0", "days"=>""} permitted: true>} permitted: true>
Run Code Online (Sandbox Code Playgroud)
这v是触发错误时变量的值
<ActionController::Parameters {"remote"=>"0", "days"=>""} permitted: true>
v.class => ActionController::Parameters
Run Code Online (Sandbox Code Playgroud)
该方法不适用于嵌套参数。非常感谢你的帮助
最好的问候法布里齐奥
模型Companyjsonbpreferences字段:
Company.new.preferences
=> { display_settings: { attr1: "" }}
Run Code Online (Sandbox Code Playgroud)
应使用标签创建以下 htmlinput字段simple_formsimple_fields_for
<input type="text" name="company[preferences][display_settings][attr1]">
Run Code Online (Sandbox Code Playgroud)
我只能按照以下说明input渲染with ,它将持久保存到数据库中:name="company[preferences][attr1]"
Company.last.preferences
=> { attr1: "" }
Run Code Online (Sandbox Code Playgroud)
我正在使用以下内容erb:
<% preferences = PreferencesDecorator.new(@company.preferences["display_settings"])
f.simple_fields_for(preferences) do |field|
preferences.each do |key, value| %>
<label for="<%= key %>"><%= key %></label>
<%= field.input_field key %>
<% end
end %>
Run Code Online (Sandbox Code Playgroud)