I have implemented rails gem gon in index method and it works fine. But when I try to implement in controller#new it is not working this is my error output:
No such file or directory # rb_sysopen - app/views/cuenta_proveedors/new.json.jbuilder
but i have already create this file.
this is my controller
def new
#cuenta_proveedor = CuentaProveedor.new
#cuentas = #negocio.cuenta_proveedors.order(:created_at)
gon.jbuilder // THIS LINE CAUSE THE ERROR SHOWN BY APPLICATION TRACE
end
i have the created the file new.json.jbuiler
json.cuenta_proveedores #cuentas do |cc|
json.proveedor cc.proveedor.nombre
json.inicial cc.monto_inicial
json.saldo cc.monto_adeudado
json.observacion cc.observacion
json.token cc.token
end
Why is this happening? I can not found any logic to this error. If you need more information ask me . Thanks
Related
I'm just trying to use the mongoid-grid_fs gem in order to upload images and files to MongoDB.
The controller code in question currently looks like this:
grid_fs = Mongoid::GridFs
encFile = File.open(attFile)
File.open(encFile, 'wb') do |f|
f.write(encData)
end
grid_file = grid_fs.put(encFile.path)
I'm getting this error:
undefined method `destroy' for nil:NilClass
/GEMS/bundler/gems/mongoid-grid_fs-2f0e12e85a24/lib/mongoid/grid_fs.rb:150:in `put'
(eval):2:in `put'
/x/app/controllers/runtime/attachments_api_controller.rb:126:in `upload'
FYI line 126 in attachments_api_controller is the grid_fs.put line.
I'm not sure what the issue is.
I have also declared require 'mongoid/grid_fs'
I have put bindings around the issue, I can confirm that encFile.path is correct and it contains valid data.
EDIT 1: I've tried different combinations of trying to put the file like
grid_fs.put(encFile) - grid_fs.put(File.open(encFile.path)) - grid_fs.put(File.read(encFile.path)) but all of these still return the same error.
I am developing Rails 4 application where have to modify existing PDF file.
User can write some comments and click then comments write in existing PDF as well. For this, i used gem 'pdf-toolkit'
But i got below error:
Error invoking PDFTK
My Code:
my_pdf = PDF::Toolkit.open("Credit_One.pdf")
my_pdf.updated_at = Time.now # ModDate
my_pdf["SomeAttribute"] = "Some value"
my_pdf.save!
Where is wrong any one have a idea.
Thanks
I'm trying to load a library from a Controller and it is throwing me this error
cannot load such file -- /xsd
It is, in fact, being loaded in the first line of the library file
require 'xsd/qname'
# {http://www.f2b.com.br/soap/wsbillingaction.xsd}F2bAcaoCobranca
# mensagem - F2bAcaoCobranca::Mensagem
# cliente - F2bAcaoCobranca::Cliente
# acao_cobranca - F2bAcaoCobranca::Acao_cobranca
class F2bAcaoCobranca
#...
end
The library's file is in the following directory:
lib
--f2b
--acao_cobranca
--wsbillingaction.rb
And my controller's action has the following lines of code
def index
require 'f2b/acao_cobranca/wsbillingaction.rb'
end
What is giving me this error? Is it some old stuff from previous versions of Ruby/Rails? How can I fix it?
wsbillingaction depend on another lib (xsd/qname), you should include it in your project or install it as a gem
I am trying to write a method that uses the EXIFR gem to retrieve data (in this case camera model) about photos as they are uploaded using Carrierwave. The current method I am using looks like this in my model:
before_save :get_exif_data
def get_exif_data
imgfile = EXIFR::JPEG.new(photo.filename)
return
self.model = imgfile.model
end
However, I get an error "No such file or directory - IMG_0953.JPG" (or another filename).
My goal is to extract the "type of camera" data using the EXIFR gem's .model method before saving. From the EXIFR gem documentation:
EXIFR::JPEG.new('IMG_6841.JPG').model # => "Canon PowerShot G3"
The error suggests to me that my photo.filename has not yet been created. How might I process the image before it is saved?
Actually, something like the following ended up working for me:
before_save :get_camera
private
def get_camera
self.model = EXIFR::JPEG.new(photo.file.path).model
end
end
Try
EXIFR::JPEG.new(Rails.root.to_s + photo.filename_url)
carrierwave return an url look like /uploads/...
its a relative path to webapp, but EXIFR::JPEG will think it a path of system file
I'm using Rack::Directory.new to map a directory in the public folder directly to the website and serve static files.
My config.ru contains:
map '/pdfs/' do
run Rack::Directory.new('./public/resources/pdfs')
end
require './app/main.rb'
run MainSinatra
I'm using a Sinatra App to run the rest of the application and using cucumber-sinatra to pre-generate some files.
When I try to load the path to the pdfs in my paths file I get an error.
features/support/paths.rb:
def path_to(page_name)
case page_name
when /dias_all/
'/pdfs'
...
end
Then on my steps file I put
visit dias_all
and I get a 404 error.
I tried adding this to the features/support/env.rb file but still got an error:
class MainSinatraWorld
...
include Rack::Test::Methods
def app
Rack::Directory.new('./public/resources/pdfs')
end
end
and then changed the step file visit to a get, but still got an error.
get('/pdfs/dias')
error:
No response yet. Request a page first. (Rack::Test::Error)
How do I test the contents of the folder through Capybara or Cucumber?
I was able to figure out how to solve this problem by changing this line in env.rb from:
Capybara.app = MainSinatra
to:
Capybara.app = eval "Rack::Builder.new {( " + File.read(File.dirname(__FILE__) +
'/../../config.ru') + "\n )}"
And this runs the application from the rack up file (config.ru) and loads all the middleware that wasn't otherwise loading.
I found the answer in this blog.