我已经从https://github.com/randym/axlsx成功安装了axlsx gem 这是我用来通过这个gem创建excel文件的控制器代码.
但是这个代码没有任何反应,而是向我展示了一个未初始化的mime错误
class Coaches::PaymentsController < ApplicationController
before_filter :authenticate_coach!
# List all the payments
def index
if !params[:sort].blank?
@payments = Payment.includes(:member).paginate(:page => params[:page], :order => sort_column + " " + sort_direction)
else
@payments = Payment.includes(:member).paginate(:page => params[:page], :order=>'id desc')
end
respond_to do |format|
format.html
# Change format to xlsx
format.xlsx
format.json { render json: @payments }
end
end
end
Run Code Online (Sandbox Code Playgroud)
其次,我尝试使用此代码:
wb = xlsx_package.workbook
wb.add_worksheet(name: "Buttons") do |sheet|
@buttons.each do |button|
sheet.add_row [button.name, button.category, button.price]
end
end
Run Code Online (Sandbox Code Playgroud)
但不幸的是,它不起作用.任何人都可以告诉我只是暗示不是解决方案来完成我的任务吗? …
我发现了一个诡计
// Define variables
var query = 'select * from data.html.cssselect where url="http://www.chucknorrisfacts.com/chuck-norris-top-50-facts" and css=".field-content a"';
var yqlAPI = 'http://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent(query) + ' &format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=?';
$.getJSON(yqlAPI, function(r){
console.log('Chuck Norris Facts:');
$.each(r.query.results.results.a, function(){ console.log('----------'); console.log(this.content);
}); });
Run Code Online (Sandbox Code Playgroud)
听起来很棒,但它不起作用.
发现这个:http://tutorialzine.com/2010/02/feed-widget-jquery-css-yql/同样的问题. https://github.com/hail2u/jquery.query-yql下载,解压缩,在服务器上运行,什么都没有.
第一个查询的YQL控制台很慢但有效.
如何在js中使用YQL?OAuth是否必要?
更新:

我正在构建一个解析器系统,它将根据请求/ cronjob解析大量不同的XML/JSON提要.我使用Laravel 4.
该线程的目的是在我的上下文中使用IoC,而不是在自定义类方法中使用硬编码的模型名称
为具有XML结构的Soccer Player提供解析器的示例,如:
<players category="Midfielders">
<player id="777">
<name>Caio Augusto Paim do Santos</name>
<statistic>
<club name="Camaçari" id="7191" league="Baiano 2" league_id="1136" season="2013" minutes="" appearences="" lineups="" substitute_in="" substitute_out="" substitutes_on_bench="" goals="" yellowcards="" yellowred="" redcards=""/>
Run Code Online (Sandbox Code Playgroud)
我在我的/ app文件夹中创建了一个名为/ parsers的附加目录.这些是自定义类,它们都在同一文件夹中扩展或实现自定义摘要/接口,并且基本上负责接收XML/JSON文件的路径并返回一个好的结构化PHP数组.
它们在autoload的composer.json中添加为: "app/parsers"
附加文件结构的屏幕截图
一切都很好,代码/类是可测试的,不依赖于另一个类,但这是问题所在.
查看XML示例,例如:
<club id="XXX" league_id="YYY" />
这是Feed俱乐部ID和Feed联盟ID,但我在数据库中有自己的ID,引用了Feed ID.
喜欢这个截图:

所以逻辑说:转到数据库,检查联盟列表中是否有来自XML文件提供的feed_id的id.如果是,请获取它,如果没有,请创建一个新联盟并获取未来参考的ID.
这需要我在我的解析器类中使用Model,现在我知道你可以使用IoC并将模型注入到控制器中,但我不确定我是否可以对我的解析器类做同样的事情......
所以在我的解析器类中间做这样的事情:
// Try to get league and season ids from database if they already exists, if not, insert
$leagueId = DB::select('SELECT id FROM league WHERE feed_id=?', array($data['league_id']));
Run Code Online (Sandbox Code Playgroud)
要么
$league = …Run Code Online (Sandbox Code Playgroud) 我正在使用Ruby on Rails 5并使用turbo-link,如下所示:
<%= javascript_include_tag 'custom-plugins', 'data-turbolinks-track' => true %>
Run Code Online (Sandbox Code Playgroud)
它在Ruby On Rails 4上运行良好,但是在Ruby on Rails版本5上有问题.一旦我点击后面,js/css没有正确加载.
任何帮助将不胜感激.
我想使用Devise登录具有相同用户模型的常规非管理员用户.所以我使用角色id作为另一个属性,一切正常.挑战在于我必须为前端用户创建自定义登录页面,注册页面和其他相关页面.当前路由文件是:
Rails.application.routes.draw do
devise_for :users, ActiveAdmin::Devise.config
ActiveAdmin.routes(self)
end
Run Code Online (Sandbox Code Playgroud)
由于我想生成新的登录表单并想要覆盖控制器,我添加了devise_for:users但它给了我一个定义的错误路由.我怎么能解决冲突?
此外,以下是有效的管理员设置:
config.authentication_method = :authenticate_user!
config.current_user_method = :current_user
Run Code Online (Sandbox Code Playgroud)
我想自定义登录页面并注册页面控制器,因为我必须在注册表单中添加一些内容.
我已经设置了模式文件,但无法为租户定义种子文件,因此它只能为租户迁移运行.此外,我还尝试在创建用户并创建其租户后创建架构.
require 'apartment/elevators/subdomain'
#
# Apartment Configuration
#
Apartment.configure do |config|
config.excluded_models = ["Admin","Contractor", "ContractorPackage","ContractorTransaction","Country","Currency","Faq","FaqCategory","Language","Package","Page","PaymentType","Setting","TempTransaction","Testimonial","Timezone","Tutorial"]
# use postgres schemas?
config.use_schemas = true
config.tenant_names = lambda{ Contractor.pluck("CONCAT('contractor_',id)") }
end
# overriding module schema file here
module Apartment
class << self
def database_schema_file
@database_schema_file=Rails.root.join('db', 'contractor_schema.rb')
end
end
end
Rails.application.config.middleware.use 'Apartment::Elevators::Subdomain'
Run Code Online (Sandbox Code Playgroud) @pytest.mark.incremental
class Test_aws():
def test_case1(self):
----- some code here ----
result = someMethodTogetResult
assert result[0] == True
orderID = result[1]
def test_case2(self):
result = someMethodTogetResult # can be only perform once test case 1 run successfully.
assert result == True
def test_deleteOrder_R53HostZonePrivate(self):
result = someMethodTogetResult
assert result[0] == True
Run Code Online (Sandbox Code Playgroud)
当前行为是:如果测试1通过,则测试2运行,如果测试2通过,则测试3运行。
我需要的是:如果test_case 1通过则应该运行test_case 3。test_case 2不应更改任何行为。有什么想法吗?
我正在使用ajax调用来上传由PHP处理的文件.应根据jquery变量将文件放在特定目录中.我可以上传文件,但无法将变量与文件一起传递.PHP报告未定义的索引错误.
Ajax代码:
var fd = new FormData();
fd.append( 'file', document.getElementById('select').files[0]);
$.ajax({
url: 'test.php',
type: 'POST',
data: fd,
processData: false,
contentType: false,
success: function(e){
// some code here
}
});
Run Code Online (Sandbox Code Playgroud)
我尝试将data属性更改为"fd +'和myVar ='+ myVar,但PHP无法正确解析数据并为$ _FILES ['file']变量以及$ _POST ['myVar']返回未定义的索引错误变量.
如何发送文件和变量?
我使用以下环境:
Server: Webrick
Rails: 3.2.6
Ruby: 1.9.3p555
Run Code Online (Sandbox Code Playgroud)
我在/ script/rails中添加了以下代码:
require 'rails/commands/server'
require 'rack'
require 'webrick'
require 'webrick/https'
if ENV['SSL'] == "true"
module Rails
class Server < ::Rack::Server
def default_options
super.merge({
:Port => 3000,
:environment => (ENV['RAILS_ENV'] || "production").dup,
:daemonize => false,
:debugger => false,
:pid => File.expand_path("tmp/pids/server.pid"),
:config => File.expand_path("config.ru"),
:SSLEnable => true,
:SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE,
:SSLPrivateKey => OpenSSL::PKey::RSA.new(
File.open("certs/project.key").read),
:SSLCertificate => OpenSSL::X509::Certificate.new(
File.open("certs/project.crt").read),
:SSLCertName => [["CN", WEBrick::Utils::getservername]],
})
end
end
end
end
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__) …Run Code Online (Sandbox Code Playgroud) ruby ×3
jquery ×2
php ×2
activeadmin ×1
ajax ×1
file ×1
javascript ×1
laravel ×1
laravel-4 ×1
parsing ×1
pytest ×1
python ×1
python-2.7 ×1
ssl ×1
turbolinks ×1
upload ×1
webrick ×1
xml ×1
yql ×1