小编Ste*_*zin的帖子

Paperclip异常:Paperclip :: AdapterRegistry :: NoHandlerError

在rails 3.2.2中使用Paperclip 3.0.1我收到此错误:

**Paperclip::AdapterRegistry::NoHandlerError** 
(No handler found for "2009-11-29-133527.jpg"):
Run Code Online (Sandbox Code Playgroud)

在我的模型中,我有:

class Product < ActiveRecord::Base
    ...
    has_many :assets 
    accepts_nested_attributes_for :assets
 end

 class Asset < ActiveRecord::Base
     belongs_to :product
     has_attached_file :image,
               :path => ":rails_root/public/system/:attachment/:id/:style/:filename",
               :url => "/system/:attachment/:id/:style/:filename", 
               :styles => { :medium => "300x300>", :thumb => "100x100>" }
  end
Run Code Online (Sandbox Code Playgroud)

例外是在:

def create
     **@product = Product.new params[:product]**
     ...
end
Run Code Online (Sandbox Code Playgroud)

与params:

{...,
 "product"=>{"title"=>"wibble1", 
             **"assets_attributes"=>{"0"=>{"image"=>"2009-11-29-133527.jpg"}
                                  },** 
             "description"=>"Who is wibble...", 
             "price"=>"23.45"
            }, 
             "commit"=>"Create Product", 
             ...}
Run Code Online (Sandbox Code Playgroud)

有谁知道发生了什么?

ruby-on-rails paperclip

40
推荐指数
4
解决办法
4万
查看次数

邪恶的PDF +字体+ heroku + rails3.2

我正在使用wicked_pdf和rails 3.2.11以及ruby 1.9.3从HTML生成PDF并部署到Heroku.

我的pdf.css.scss.erb:

<% app_fullhost = Constants["app_fullhost"] %>

@font-face {
  font-family:'DosisMedium'; font-style:normal; font-weight:500;
  src: url(<%=app_fullhost%>/app/font/dosis/Dosis-Medium.ttf) format('woff');
}

*, body {
  font-family: "DosisLight", 'Times New Roman', 'Arial', sans-serif;
} 
Run Code Online (Sandbox Code Playgroud)

app_fullhost在开发或生产中,确切的主机在哪里.

我的pdf布局包括:

%html{:lang => I18n.locale}
  %head
    %meta{:charset => "utf-8"}
    %title= content_for?(:title) ? yield(:title) : Settings.app_name
    = wicked_pdf_stylesheet_link_tag "pdf"
Run Code Online (Sandbox Code Playgroud)

在production.rb我有

config.assets.precompile +=%w(pdf.css)
Run Code Online (Sandbox Code Playgroud)

这在开发中没有问题,但在Heroku上,pdf文件不会加载所需的字体.我也尝试过不同的解决方案,比如在production.rb中添加这些解决方案:

config.assets.paths << "#{Rails.root}/app/assets/fonts"
config.assets.precompile += %w(*.svg *.eot *.woff *.ttf) 
config.assets.precompile += %w(.svg .eot .woff .ttf) 
Run Code Online (Sandbox Code Playgroud)

我也尝试改变(在pdf.css.scss.erb中):

@font-face {
  font-family:'Dosis'; font-style:normal; font-weight:500;
  src: url('Dosis-Medium.ttf') format('woff');
}
Run Code Online (Sandbox Code Playgroud)

要么 …

fonts heroku wicked-pdf ruby-on-rails-3.2

11
推荐指数
2
解决办法
3170
查看次数

如何在加载函数之外访问 SvelteKit fetch 实现

我有一个 SvelteKit 客户端,它通过 GRAPHQL API 接口与后端进行通信。SvelteKit 应用程序只有一个独立端点,仅通过一个 POST 请求处理程序运行请求,例如 /src/routes/endpoint.json.ts

我有一个模块,比如 Address.svelte,它公开了一个 smui 自动完成小部件来搜索我所在国家/地区的城市。当用户输入该组件时,该组件会动态地获取城市,如下所示:

   [..] 
   import {findListCity, type ICity } from '$lib/city'
   export let svelteKitFetch
   [...]
   
   async function searchCities(input: string): Promise<ICity[] | false> {
        
            [...]

            return new Promise( ( resolve, reject) => {

                debounceSearchTimer = setTimeout( async () => {
                    try {
                        options = await findCityList({ 
                            fetch: svelteKitFetch, 
                            pagination: { ... },
                            searchOptions: {... } 
                        }); 
                    } catch(e) {
                        console.log("An error occurred ", e);
                        reject(e);
                    }

                    // Return a list …
Run Code Online (Sandbox Code Playgroud)

sveltekit

7
推荐指数
1
解决办法
1925
查看次数

使用 https 运行 sveltekit dev

在开发环境中是否可以使用 https 运行 SvelteKit 应用程序?\n我尝试运行

\n
npm run dev -- --https  \n
Run Code Online (Sandbox Code Playgroud)\n

vite启动服务器成功:

\n
VITE v3.0.2  ready in 359 ms\n\n  \xe2\x9e\x9c  Local:   https://localhost:5173/\n  \xe2\x9e\x9c  Network: [...] \n
Run Code Online (Sandbox Code Playgroud)\n

但我无法连接到 https://localhost:5173\nchrome 说:ERR_SSL_VERSION_OR_CIPHER_MISMATCH

\n

我还尝试编辑 vite.config.js 添加我的证书:

\n
https: {\n    key: readFileSync( `${__dirname}/../server/key.pem`),\n    cert: readFileSync(`${__dirname}/../server/cert.pem`),\n}\n
Run Code Online (Sandbox Code Playgroud)\n

我还尝试在这篇文章之后使用 mkcert() :

\n

在本地主机上访问 https

\n

但它会导致同样的错误

\n

然后我尝试使用 mkcert 作为插件:

\n
const config = {\n    \n    server: {       \n        https: true\n    },\n\n    plugins: [sveltekit(), mkcert()],\n\n}; \n
Run Code Online (Sandbox Code Playgroud)\n

这次,在第一次加载时,它似乎可以工作,但是使用 SvelteKit goto() 加载其他页面会导致以下不同的错误:

\n
TypeError …
Run Code Online (Sandbox Code Playgroud)

svelte sveltekit

5
推荐指数
2
解决办法
6354
查看次数