shared items
Thursday, August 27, 2009
Thursday, August 6, 2009
Rails 2.3 and Mysql 5.1
The title says it all. I wish Ruby on Rails wasn’t so difficult to get set up on Windows. It sounds like most Ruby on Rails developers are Mac OS X or Linux users.
I was just trying to get a basic app set up with MySQL 5.1, Rails 2.3 and Ruby 1.8.6 and got this error when trying to run rake db:migrate:
rake aborted!
undefined method `each’ for #
I found an answer here:
http://www.nabble.com/rake-aborted!-undefined-method-%60each%27-for–%3CMysql:-td20760472.html
Looks like most people uninstalled MySQL 5.1 and went back to 5.0. People also seemed to have better luck with Postgresql.
Source : http://peterskim.org/2009/04/12/mysql-51-with-rails-23ruby-186-on-windows-doesnt-work/
Also Comments :
I’m running MYSQL 5.1 and had a similar problem. I have Ruby 1.8.6. I followed these instructions and the undefined method error was resolved when running rake.
> The problem is that libmysql.dll shipped with Mysql doesn’t play well
> with ruby 2.2..
>
> The solution is to download the libmysql.dll from:
>
> http://instantrails.rubyforge.org/svn/trunk/InstantRails-win/InstantRails/mysql/bin/libmySQL.dll
I was just trying to get a basic app set up with MySQL 5.1, Rails 2.3 and Ruby 1.8.6 and got this error when trying to run rake db:migrate:
rake aborted!
undefined method `each’ for #
I found an answer here:
http://www.nabble.com/rake-aborted!-undefined-method-%60each%27-for–%3CMysql:-td20760472.html
Looks like most people uninstalled MySQL 5.1 and went back to 5.0. People also seemed to have better luck with Postgresql.
Source : http://peterskim.org/2009/04/12/mysql-51-with-rails-23ruby-186-on-windows-doesnt-work/
Also Comments :
I’m running MYSQL 5.1 and had a similar problem. I have Ruby 1.8.6. I followed these instructions and the undefined method error was resolved when running rake.
> The problem is that libmysql.dll shipped with Mysql doesn’t play well
> with ruby 2.2..
>
> The solution is to download the libmysql.dll from:
>
> http://instantrails.rubyforge.org/svn/trunk/InstantRails-win/InstantRails/mysql/bin/libmySQL.dll
Tuesday, July 28, 2009
Date Time format for Rails Ruby
------------------------------------------------------------------ Time#strftime
time.strftime( string ) => string
---------------------------------------------------------------------------------
Formats time according to the directives in the given format string. Any text not listed as a directive will be passed through to the output string.
"
Format meaning:
%a - The abbreviated weekday name (``Sun'')
%A - The full weekday name (``Sunday'')
%b - The abbreviated month name (``Jan'')
%B - The full month name (``January'')
%c - The preferred local date and time representation
%d - Day of the month (01..31)
%H - Hour of the day, 24-hour clock (00..23)
%I - Hour of the day, 12-hour clock (01..12)
%j - Day of the year (001..366)
%m - Month of the year (01..12)
%M - Minute of the hour (00..59)
%p - Meridian indicator (``AM'' or ``PM'')
%S - Second of the minute (00..60)
%U - Week number of the current year,
starting with the first Sunday as the first
day of the first week (00..53)
%W - Week number of the current year,
starting with the first Monday as the first
day of the first week (00..53)
%w - Day of the week (Sunday is 0, 0..6)
%x - Preferred representation for the date alone, no time
%X - Preferred representation for the time alone, no date
%y - Year without a century (00..99)
%Y - Year with century
%Z - Time zone name
%% - Literal ``%'' character
t = Time.now
t.strftime("Printed on %m/%d/%Y") #=> "Printed on 04/09/2003"
t.strftime("at %I:%M%p") #=> "at 08:56AM"
"
time.strftime( string ) => string
---------------------------------------------------------------------------------
Formats time according to the directives in the given format string. Any text not listed as a directive will be passed through to the output string.
"
Format meaning:
%a - The abbreviated weekday name (``Sun'')
%A - The full weekday name (``Sunday'')
%b - The abbreviated month name (``Jan'')
%B - The full month name (``January'')
%c - The preferred local date and time representation
%d - Day of the month (01..31)
%H - Hour of the day, 24-hour clock (00..23)
%I - Hour of the day, 12-hour clock (01..12)
%j - Day of the year (001..366)
%m - Month of the year (01..12)
%M - Minute of the hour (00..59)
%p - Meridian indicator (``AM'' or ``PM'')
%S - Second of the minute (00..60)
%U - Week number of the current year,
starting with the first Sunday as the first
day of the first week (00..53)
%W - Week number of the current year,
starting with the first Monday as the first
day of the first week (00..53)
%w - Day of the week (Sunday is 0, 0..6)
%x - Preferred representation for the date alone, no time
%X - Preferred representation for the time alone, no date
%y - Year without a century (00..99)
%Y - Year with century
%Z - Time zone name
%% - Literal ``%'' character
t = Time.now
t.strftime("Printed on %m/%d/%Y") #=> "Printed on 04/09/2003"
t.strftime("at %I:%M%p") #=> "at 08:56AM"
"
Sunday, May 31, 2009
magicjack and Win xp issues
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E965-E325-11 CE-BFC1-08002BE10318
Hopefully these simple directions will help those who are not master computer techs like me:) God knows I couldn't get it right to save my life! But a light bulb went off in my head and this is how I did it. Almost embarassing to mention;
When looking for this file in device manager please consider the following Steps:
To resolve this problem, remove the affected filter drivers. To do this, follow these steps:
1. Click Start, type regedit in the Start Search box, and then click regedit in the Programs list.
If you are prompted for an administrator password or confirmation, type your password, or click Continue.
2. Locate, and then click the following registry subkey:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E965-E325-11CE-BFC1-08002BE10318}
ie., 1. Go to HKEY_LOCAL_MACHINE and click on it.
2. part of the sub directory will appear
3. then click on SYSTEM
4. You will then see Current Control Set click on it
5. And so on......get the picture now!
Whew! Now follow the rest of the directions and you should have any additional problems
Caution There can be many instances of the registry subkey that is mentioned in step 2. You must make sure that you are in the appropriate registry subkey before modifying the UpperFilters and the LowerFilters values. To verify that you are in the appropriate registry subkey, make sure that the Default data value is DVD/CD-ROM and the Class data value is CDROM.
3. In the right pane, right-click UpperFilters, and then click Delete.
4. Click Yes to confirm the removal of the UpperFilters registry entry.
5. In the right pane, right-click LowerFilters, and then click Delete.
6. Click Yes to confirm the removal of the LowerFilters registry entry.
7. Exit Registry Editor, and then restart the computer.
Source : http://forums.cnet.com/5208-12546_102-0.html?threadID=241915&start=45&tag=forum-w;forums06
Hopefully these simple directions will help those who are not master computer techs like me:) God knows I couldn't get it right to save my life! But a light bulb went off in my head and this is how I did it. Almost embarassing to mention;
When looking for this file in device manager please consider the following Steps:
To resolve this problem, remove the affected filter drivers. To do this, follow these steps:
1. Click Start, type regedit in the Start Search box, and then click regedit in the Programs list.
If you are prompted for an administrator password or confirmation, type your password, or click Continue.
2. Locate, and then click the following registry subkey:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E965-E325-11CE-BFC1-08002BE10318}
ie., 1. Go to HKEY_LOCAL_MACHINE and click on it.
2. part of the sub directory will appear
3. then click on SYSTEM
4. You will then see Current Control Set click on it
5. And so on......get the picture now!
Whew! Now follow the rest of the directions and you should have any additional problems
Caution There can be many instances of the registry subkey that is mentioned in step 2. You must make sure that you are in the appropriate registry subkey before modifying the UpperFilters and the LowerFilters values. To verify that you are in the appropriate registry subkey, make sure that the Default data value is DVD/CD-ROM and the Class data value is CDROM.
3. In the right pane, right-click UpperFilters, and then click Delete.
4. Click Yes to confirm the removal of the UpperFilters registry entry.
5. In the right pane, right-click LowerFilters, and then click Delete.
6. Click Yes to confirm the removal of the LowerFilters registry entry.
7. Exit Registry Editor, and then restart the computer.
Source : http://forums.cnet.com/5208-12546_102-0.html?threadID=241915&start=45&tag=forum-w;forums06
Wednesday, May 20, 2009
load files in jar
If you use a filename, then the filename has to refer to a real file. But if you use a "resource name," that resource might be a file or it might be a component of a JAR (or theoretically something else altogether.)
The magic method(s) in this case are the family of loadResource() methods. For example, Class.getResource().
If youve got a class foo/bar/Test.class inside a JAR file, and also a foo/bar/Image.jpg, then inside the Test class you can refer to Image.jpg using
URL theURL = getClass().getResource("Image.jpg");
and then pass the URL to ImageIcon's constructor for example.
Source : http://www.coderanch.com/t/276412/Streams/java/Load-file-inside-JAR
The magic method(s) in this case are the family of loadResource() methods. For example, Class.getResource().
If youve got a class foo/bar/Test.class inside a JAR file, and also a foo/bar/Image.jpg, then inside the Test class you can refer to Image.jpg using
URL theURL = getClass().getResource("Image.jpg");
and then pass the URL to ImageIcon's constructor for example.
Source : http://www.coderanch.com/t/276412/Streams/java/Load-file-inside-JAR
Monday, May 11, 2009
Inflater Deflater
public class Inflater
extends Object
This class provides support for general purpose decompression using popular ZLIB compression library. The ZLIB compression library was initially developed as part of the PNG graphics standard and is not protected by patents. It is fully described in the specifications at the java.util.zip package description.
The following code fragment demonstrates a trivial compression and decompression of a string using Deflater and Inflater.
// Encode a String into bytes
String inputString = "blahblahblah??";
byte[] input = inputString.getBytes("UTF-8");
// Compress the bytes
byte[] output = new byte[100];
Deflater compresser = new Deflater();
compresser.setInput(input);
compresser.finish();
int compressedDataLength = compresser.deflate(output);
// Decompress the bytes
Inflater decompresser = new Inflater();
decompresser.setInput(output, 0, compressedDataLength);
byte[] result = new byte[100];
int resultLength = decompresser.inflate(result);
decompresser.end();
// Decode the bytes into a String
String outputString = new String(result, 0, resultLength, "UTF-8");
extends Object
This class provides support for general purpose decompression using popular ZLIB compression library. The ZLIB compression library was initially developed as part of the PNG graphics standard and is not protected by patents. It is fully described in the specifications at the java.util.zip package description.
The following code fragment demonstrates a trivial compression and decompression of a string using Deflater and Inflater.
// Encode a String into bytes
String inputString = "blahblahblah??";
byte[] input = inputString.getBytes("UTF-8");
// Compress the bytes
byte[] output = new byte[100];
Deflater compresser = new Deflater();
compresser.setInput(input);
compresser.finish();
int compressedDataLength = compresser.deflate(output);
// Decompress the bytes
Inflater decompresser = new Inflater();
decompresser.setInput(output, 0, compressedDataLength);
byte[] result = new byte[100];
int resultLength = decompresser.inflate(result);
decompresser.end();
// Decode the bytes into a String
String outputString = new String(result, 0, resultLength, "UTF-8");
Sunday, May 10, 2009
each_hash error with Rails 2.2 and mysql 5.1
Rails 2.2 MySQL removed error SOLUTION
by protech_v2 » Mon Dec 15, 2008 8:04 pm
If at any point when you've upgraded to Rails 2.2. you get the following error on Windows:
"!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql."
the problem is because MySQL 5.1 client library doesn't play well with Rails - the solution is simple however:
- download older MySQL client library, for example one from InstantRails: http://instantrails.rubyforge.org/svn/t ... bmySQL.dll
- copy the downloaded file to C:\Ruby\bin (or wherever you installed Ruby)
- restart MySQL server
That's it! Just thought I'd share this with others, lost me an hour of researching.
Good luck!
REF
by protech_v2 » Mon Dec 15, 2008 8:04 pm
If at any point when you've upgraded to Rails 2.2. you get the following error on Windows:
"!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql."
the problem is because MySQL 5.1 client library doesn't play well with Rails - the solution is simple however:
- download older MySQL client library, for example one from InstantRails: http://instantrails.rubyforge.org/svn/t ... bmySQL.dll
- copy the downloaded file to C:\Ruby\bin (or wherever you installed Ruby)
- restart MySQL server
That's it! Just thought I'd share this with others, lost me an hour of researching.
Good luck!
REF
Subscribe to:
Posts (Atom)