将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 theJSON
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
最满意答案
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的元素(Element having same xpath)[2023-04-12]
您必须在括号中包含完整的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中不同?(distinct in Xpath?)[2023-08-28]
纯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)]) -
Selenium中的Xpath(Xpath in Selenium)[2022-10-01]
我认为这是你的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 ... -
xpath中的变量(variable in xpath)[2022-03-24]
你想要做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 Xpath帮助(PHP Xpath help)[2023-11-26]
以下是在PHP中使用XML的一个很好的概述。 我建议使用SimpleXML和DOM来解析它,而不是使用XPath。 例如...Great American Novel Cliff re ... -
XPath中的任意连接(Arbitrary joins in XPath)[2022-03-01]
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 ... -
用于通过XPath将任意XML字符串插入XML文档的代码(Code to insert arbitrary XML string into XML document by XPath)[2020-09-08]
如果代码片段结构良好,我见过的大多数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 ... -
XPath - (// first // *)[1] vs // first // * [1](XPath - (//first//*)[1] vs //first//*[1])[2022-08-01]
在这两种情况下, //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,因为字符串值定义的分层特性意味着父元素和子元素的字符串值之间的子字符串包含。)无论如何,这 ...