Tuesday, September 6, 2011
Monday, June 20, 2011
ruby 1.9.2 restful_authentication plugin unknown encoding name: mule-utf-8 issue
The issue
=> Booting WEBrick
=> Rails 2.3.10 application starting on http://0.0.0.0:3000
C:/Users/project/vendor/plugins/restful-authentication/lib/authentication/by_cookie_token.rb:1: unknown encoding name: mule-utf-8 (ArgumentError)
from:29:in `require'
from:29:in `require'
To fix this
replace line no 1 (# -*- coding: mule-utf-8 -*-) of /vendor/plugins/restful-authentication/lib/authentication/by_cookie_token.rb
with # -*- coding: utf-8 -*-
=> Booting WEBrick
=> Rails 2.3.10 application starting on http://0.0.0.0:3000
C:/Users/project/vendor/plugins/restful-authentication/lib/authentication/by_cookie_token.rb:1: unknown encoding name: mule-utf-8 (ArgumentError)
from
from
To fix this
replace line no 1 (# -*- coding: mule-utf-8 -*-) of /vendor/plugins/restful-authentication/lib/authentication/by_cookie_token.rb
with # -*- coding: utf-8 -*-
Monday, May 16, 2011
Wednesday, March 16, 2011
Zip multiple files and download as attachment using rubyzip gem.
rubyzip is a lib for creating / working with zip archives in ruby.
» gem install rubyzip
Sample code
require 'zip/zip'
require 'zip/zipfilesystem'
def download_all
attachments = Upload.find(:all, :conditions => ["source_id = ?", params[:id]])
zip_file_path = "#{RAILS_ROOT}/uploads/download_all.zip"
# see if the file exists already, and if it does, delete it.
if File.file?(zip_file_path)
File.delete(zip_file_path)
end
# open or create the zip file
Zip::ZipFile.open(zip_file_path, Zip::ZipFile::CREATE) { |zipfile|
attachments.each do |attachment|
#document_file_name shd contain filename with extension(.jpg, .csv etc) and url is the path of the document.
zipfile.add( attachment.document_file_name, attachment.document.url)
end
}
#send the file as an attachment to the user.
send_file zip_file_path, :type => 'application/zip', :disposition => 'attachment', :filename => "download_all.zip"
end
» gem install rubyzip
Sample code
require 'zip/zip'
require 'zip/zipfilesystem'
def download_all
attachments = Upload.find(:all, :conditions => ["source_id = ?", params[:id]])
zip_file_path = "#{RAILS_ROOT}/uploads/download_all.zip"
# see if the file exists already, and if it does, delete it.
if File.file?(zip_file_path)
File.delete(zip_file_path)
end
# open or create the zip file
Zip::ZipFile.open(zip_file_path, Zip::ZipFile::CREATE) { |zipfile|
attachments.each do |attachment|
#document_file_name shd contain filename with extension(.jpg, .csv etc) and url is the path of the document.
zipfile.add( attachment.document_file_name, attachment.document.url)
end
}
#send the file as an attachment to the user.
send_file zip_file_path, :type => 'application/zip', :disposition => 'attachment', :filename => "download_all.zip"
end
Tuesday, January 18, 2011
Monday, January 3, 2011
Thinking Sphinx Issue: Connection to Sphinx Daemon (searchd) failed
Thinking Sphinx may will not work when rails files path has spaces in it, so "My Documents" or "firstname lastname" will not work.
So either create a new directory under c:\ and then sphinx.yml folder into rails config folder and add these into it
development:
bin_path: C:/Sphinx/bin
config_file: C:/Users/projects/rails_app/config/development.sphinx.conf
You can also create a new account and then make sure if all the path is set in environment variables.
and then if you follow the above instructions and if you try rake ts:index then thinking sphinx will work fine.
So either create a new directory under c:\ and then sphinx.yml folder into rails config folder and add these into it
development:
bin_path: C:/Sphinx/bin
config_file: C:/Users/projects/rails_app/config/development.sphinx.conf
You can also create a new account and then make sure if all the path is set in environment variables.
and then if you follow the above instructions and if you try rake ts:index then thinking sphinx will work fine.
Subscribe to:
Posts (Atom)