首页 \ 问答 \ 将JSON数据传输到Heroku Rails应用程序(Transfer JSON data to Heroku Rails application)

将JSON数据传输到Heroku Rails应用程序(Transfer JSON data to Heroku Rails application)

我是Rails的新手并注意到我的本地环境中没有任何数据被使用heroku run rake db:migrate命令推送到Heroku环境。

特别是我想知道如何将JSON数据传输到Heroku环境。

宝石文件:

source 'https://rubygems.org'

gem 'figaro'
gem 'angular-rails'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.1'
# Use postgresql as the database for Active Record
gem 'pg'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-script', '~> 2.2.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
# gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

# Use ActiveModel has_secure_password
gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'

  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'

  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
gem 'rails_12factor', group: :production

end

/config/environments/production.rb:

Rails.application.configure do

  config.cache_classes = true


  config.eager_load = true

  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true


  config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?

  config.assets.js_compressor = :uglifier

  config.assets.compile = true


  config.assets.digest = true


  config.log_level = :debug


  config.i18n.fallbacks = true

  config.active_support.deprecation = :notify

  config.log_formatter = ::Logger::Formatter.new

  config.active_record.dump_schema_after_migration = false

  config.action_mailer.delivery_method = :smtp
end

角度控制器:

myApp.controller("BlogController", function($scope, $http){
  $http.get('/assets/blogs.json').success(function(data){
    $scope.blogs = data;

    String.prototype.trunc = String.prototype.trunc ||
      function(n){
      // this will return a substring and
      // if its larger than 'n' then truncate and append '...' to the string and return it.
      // if its less than 'n' then return the 'string'
      return this.length>n ? this.substr(0,n-1)+'...' : this;
    };

  });
});

我在部署环境的控制台中也收到以下错误: Error: Unknown provider: eProvider <- e


I am quite new to Rails and noticed that none of my data from my local environment was being pushed to the Heroku environment using the heroku run rake db:migrate command.

In particular I was wondering how to transfer the JSON data to the Heroku environment.

Gem File:

source 'https://rubygems.org'

gem 'figaro'
gem 'angular-rails'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.1'
# Use postgresql as the database for Active Record
gem 'pg'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-script', '~> 2.2.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
# gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

# Use ActiveModel has_secure_password
gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'

  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'

  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
gem 'rails_12factor', group: :production

end

/config/environments/production.rb:

Rails.application.configure do

  config.cache_classes = true


  config.eager_load = true

  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true


  config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?

  config.assets.js_compressor = :uglifier

  config.assets.compile = true


  config.assets.digest = true


  config.log_level = :debug


  config.i18n.fallbacks = true

  config.active_support.deprecation = :notify

  config.log_formatter = ::Logger::Formatter.new

  config.active_record.dump_schema_after_migration = false

  config.action_mailer.delivery_method = :smtp
end

Angular Controller:

myApp.controller("BlogController", function($scope, $http){
  $http.get('/assets/blogs.json').success(function(data){
    $scope.blogs = data;

    String.prototype.trunc = String.prototype.trunc ||
      function(n){
      // this will return a substring and
      // if its larger than 'n' then truncate and append '...' to the string and return it.
      // if its less than 'n' then return the 'string'
      return this.length>n ? this.substr(0,n-1)+'...' : this;
    };

  });
});

I am also receiving the following error in my console for the deployed environment: Error: Unknown provider: eProvider <- e


原文:https://stackoverflow.com/questions/33492469
更新时间:2022-03-06 18:03

最满意答案

XPath 1.0

无法单独在XPath中完成。

XPath 2.0

for $b in /root/mybonds/bond 
    return if(/root/auctions/bond[type = $b/type and amount = $b/amount])
               then $b
               else ()

XPath 1.0

Cannot be done in XPath alone.

XPath 2.0

for $b in /root/mybonds/bond 
    return if(/root/auctions/bond[type = $b/type and amount = $b/amount])
               then $b
               else ()

相关问答

更多
  • 您必须在括号中包含完整的xpath。 试试以下: driver.findElement(By.xpath("(//*[@id='imgIRBDate'])[2]")).click(); You have to enclose complete xpath in brackets. Try following: driver.findElement(By.xpath("(//*[@id='imgIRBDate'])[2]")).click();
  • 在XPath 1.0中 , /运算符要求左边的操作数是选择节点集的类型,右边的操作数是相对XPath表达式 - 也是选择节点集的类型。 因此,任何计算为简单值(number,string,boolean)的expr1都不能用于/的左侧。 对于/的右侧参数,这是完全正确的。 无效的XPath 1.0表达式的示例 : string(/foo)/bar count(//foo)/bar (/foo/baz = 3)/bar /foo/count(bar) 在XPath 2.0中 ,仍然需要在expr1/e ...
  • 纯XPath 1.0 - 一线 : 使用 : count(/*/group/user[not(. = ../following-sibling::group/user)]) A pure XPath 1.0 -- one-liner: Use: count(/*/group/user[not(. = ../following-sibling::group/user)])
  • 我认为这是你的xpath导致问题,你的元素也不是可点击的视图 以下代码经过测试并为我工作 import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import or ...
  • 你想要做eval()函数所做的事情,所以任何解决方案都会遇到与eval相同的问题。 您可以考虑的另一种方法是生成查询然后执行它,但它会有完全相同的问题。 如果您认为将字符串限制为XPath表达式的子集(例如,没有谓词或没有函数调用)可能更安全,那么您可以尝试使用简单的正则表达式测试这些条件。 You want to do what the eval() function does, so any solution is going to have the same problems as eval. The ...
  • 以下是在PHP中使用XML的一个很好的概述。 我建议使用SimpleXML和DOM来解析它,而不是使用XPath。 例如... Great American Novel Cliff re ...
  • XPath 1.0 无法单独在XPath中完成。 XPath 2.0 for $b in /root/mybonds/bond return if(/root/auctions/bond[type = $b/type and amount = $b/amount]) then $b else () XPath 1.0 Cannot be done in XPath alone. XPath 2.0 for $b in /root/myb ...
  • 如果代码片段结构良好,我见过的大多数DOM实现也将支持非标准的DocumentFragment节点类型,它允许您从字符串中注入dom节点。 编辑:快速谷歌搜索抛出一些JavaDocs: http : //download.oracle.com/javase/1.4.2/docs/api/org/w3c/dom/DocumentFragment.html IIRC api的工作原理如下(伪代码): parent = find_parent_node_of_fragment(document); fragme ...
  • 在这两种情况下, //first选择所有first元素,然后//first//*选择//first//*所有元素后代。 然后,区别是: (//first//*)[1]从所有这些元素中选择,只选择第一个元素。 //first//*[1]从所有这些元素中选择每个第一个孩子 。 正如您在XML中看到的那样, second是由XPath #1选择的,因为它是第一个后代中的first 。 (你的元素名称选择有点不理想。) second和third都是由XPath #2选择的,因为它们都是各自兄弟姐妹中的第一个 。 I ...
  • 由于函数名称1的不幸选择,许多人在XPath中错误地使用了contains()函数的用途: XPath contains()不检查元素的包含。 XPath contains()检查子字符串遏制。 因此, tr[contains(.,input)]不会做你认为它做的事。 它实际上选择了tr元素,其中的字符串值包含的子字符串等于第一个直接子元素的字符串值; 看到这个答案进一步的细节。 (有趣的是,这样的谓词简化为true,因为字符串值定义的分层特性意味着父元素和子元素的字符串值之间的子字符串包含。)无论如何,这 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)