Archive for the ‘rails’ Category

Open source is wide open: Calling RAKE tasks

Tuesday, December 15th, 2009

Open source is wide open: Calling RAKE tasks.

Good to know.

Fix for Windows + Rails 2.2 + Mysql 5.1 = error

Friday, September 25th, 2009

If you get this error : Mysql::Error: query: not connected: or one just like it, it’s because you need an older DLL.. Which I just happen to have found, because I needed to fix this problem too!
libmySQL.dll

Enjoy.

Rails authentication tutorial

Monday, September 14th, 2009

Just a link:

http://www.databaseapplications.com.au/authentication.jsp

Something for me to read and digest later when I have time.

Connecting to Sybase with Rails on Windows XP

Friday, September 11th, 2009

This is known to work on ASE 12.5.1 – you’re welcome to let me know what else worked, I am particularly curious about later versions of Sybase ASE, such as 15.

Prerequisites:

  1. Sybase PC Client 12.52
  2. The Ruby Sybase  files
  3. gem install activerecord-sybase-adapter -s http://gems.rubyonrails.org

Put the Sybase files in C:\ruby\lib\ruby\site_ruby\1.8\i386-msvcrt .

Copy all the DLLs in %SYBASE%\OCS-12_5\dll and put them in %RUBY%\bin (if you are not familiar with Windows notation, this simply means to go where you installed each of Sybase and Ruby and then go to the proper subdirectory). Why all of them? Well, because I’m too lazy to know which ones we -do- need.

Set some environment variables, just to make sure Sybase works fine:

Right-click on My Computer, Properties > Advanced > Environment Variables
If you have full permissions, go ahead and add those as SYSTEM VARIABLES.. Otherwise, well, only for your user (but aren’t you doing this on a server?).

SYBASE=c:\sybase    (where you installed Sybase).

JDBC_HOME=c:\sybase\jConnect-6_0   (again, where you installed Sybase, then the subdirectory).

CLASSPATH=%JDBC_HOME%\classes\jconn3.jar (just make sure that’s the right number).

If you’re going to create a user on your Sybase server for specific Rails usage, it needs to have SELECT permissions on the following : sysobjects, syscolumns, systypes, syscomments.

Edit your %SYBASE%\ini\sql.ini and add the information for your server in there.

Next.. In Rails, the magic will look like this in database.yml :

production:
adapter: sybase
database: <YOUR_DB_HERE>
username: <USERNAME>
password: <PASSWORD>
host: <NAME_GIVEN_IN_SQL_INI_HERE>

And that should be pretty much it!

Don’t forget to edit your model if you’re working with legacy data:

class Patient < ActiveRecord::Base
set_table_name "some_odd_name"
set_primary_key "some_primary_key_column"
end

HAML in Netbeans

Friday, September 4th, 2009

Short post to give a link to the HAML plugin for Netbeans:

http://mediacast.sun.com/details.jsp?id=3759

http://mediacast.sun.com/users/~tor/media/org-netbeans-modules-haml.nbm/details

Download and install

http://wiki.netbeans.org/FaqPluginInstall

And I get to test my wordpress-livejournal-twitter-facebook crossposting mania!

Rails, HAML, alternatible CSS for tables

Wednesday, September 2nd, 2009

If you’ve done any kind of table display in Rails, you’ve probably discovered the useful ‘cycle’ method:

“>

This works after you’ve set two CSS classes between which you want to alternate – in my example, even and odd, because I have such amazing imagination. Come to think of it, to make my code more readable, it should be ‘lightbg’ and ‘darkbg’, or something similar. I’ll fix that.

But yeah – how do you do that in HAML?
Piece of CAKE (in this case, it is not a lie).

%tr{:class => cycle(‘even’, ‘odd’) }

www.learningrails.com tutorial – screencast 14, in_place_editing

Thursday, April 23rd, 2009

You’ll notice, if you follow those screencasts (around now, anyway, as the plugin’s code is likely to change, or maybe the screencasts themselves) that when you add in_place_editing, you suddenly get broken HTML..

The fix is thankfully easy!

vendors > plugins > in_place_editing > lib > in_place_macros_helper.rb
Line 79:
tag = content_tag(tag_options.delete(:tag), h(instance_tag.value(instance_tag.object)), tag_options)

Change to :
tag = content_tag(tag_options.delete(:tag), instance_tag.value(instance_tag.object), tag_options)

And you’re set!