A blog about real-world software engineering and development problems and solutions.
Saturday, December 15, 2007
Session problems with Mongrel and Jruby on rails
If you get a "wrong number of arguments(2 for 1)" in the stale_session_check method when running your jruby ruby on rails application, the problem may be your sessions. Clear the sessions and delete all rows from the sessions database table if you are using one. Then add to environment.rb:
config.action_controller.session = { :session_key => "_myapp_session", :secret => "some secret phrase of at least 30 characters" }
The code has to be inside the Rails::Initializer.run do |config| block.
Friday, December 14, 2007
NetBeans' rake create WAR for linux problem
At least in linux, NetBeans' rake create WAR will fail when there is file that contains a space in its name. So please, make sure none of your files in the whole rails project have a space in the filename.
Monday, December 10, 2007
Rubyscript2Exe is not deleting the temp files once it is done: SOLVED!
Is your Ruby on rails application packed in a exe created by Rubyscript2Exe? Is Ruby2Exe not deleting the temp files once it is done? I came out with the solution of deleting the files of previous run:
1. Replace the contents of init.rb with this:
require "rubyscript2exe"
require "fileutils"
at_exit do
require "irb"
require "drb/acl"
require "dbi"
require "dbd/ODBC/ODBC"
#Add the libraries you need
end
if RUBYSCRIPT2EXE.is_compiled?
ee_base_folder = File.expand_path(RUBYSCRIPT2EXE.appdir + "/../..")
ee_folder = File.expand_path(RUBYSCRIPT2EXE.appdir + "/..")
name_parts = ee_folder.split(".")
curr_ee_folder_number = name_parts[3].to_i
last_ee_folder_number = curr_ee_folder_number - 1
Dir.entries(ee_base_folder).each do |folder|
if (folder != ".") and (folder != "..") and (folder.split(".")[3].to_i != curr_ee_folder_number)
folder_to_del = ee_base_folder + "/" + folder
puts "deleting " + folder_to_del
FileUtils.remove_dir(folder_to_del, true)
end
end
end
load "script/server"
2. Before running your application make sure you run this windows batch command to delete the temporary files created by tar2script:
erase /F /S /Q "%USERPROFILE%\Local Settings\Temp\tar2rubyscript*.*"
Wednesday, December 05, 2007
Database configuration sample for accessing MS SQL in Jruby's rails
Use NetBeans to create the rails project using Jruby. Make sure you select "use JDBC". The database yml for connecting to MS SQL through ODBC:
development: adapter: jdbc username: MYUSERNAME password: "14 if your password starts with a number enclose the password in double quotes" driver: sun.jdbc.odbc.JdbcOdbcDriver url: jdbc:odbc:MYDNSNAME
Subscribe to:
Posts (Atom)