No association found for name `products'. Has it been defined yet?

May 24th, 2010

Working on a project, I had to make some changes to the associations – where Product_Lines had many Products to Product_Lines has one Product.  (The reason behind this is a whole other story.)

This is the error I got:

No association found for name `products’. Has it been defined yet?

I had changed the Product_Lines model to has_one Product.  But, I had over looked the accepts_nested_attributes_for line.  I changed :products to :product and it fixed it.

Andrew Development ,

Errors using Capistrano

April 28th, 2010

“** [out :: myserver] deploy is not in the sudoers file.  This incident will be reported.”  — Solution is here.

Read more…

Andrew Development , , , , ,

Windows 2003 – Login Screen is Black Except for Logo – Part 2

April 14th, 2010

Here are the default registry settings for the instructions mention in the MS KB http://support.microsoft.com/kb/906510.

Windows Registry Editor Version 5.00
[HKEY_USERS\.DEFAULT\Control Panel\Colors]
“ActiveBorder”=”212 208 200″
“ActiveTitle”=”10 36 106″
“AppWorkSpace”=”128 128 128″
“Background”=”102 111 116″
“ButtonAlternateFace”=”181 181 181″
“ButtonDkShadow”=”64 64 64″
“ButtonFace”=”212 208 200″
“ButtonHilight”=”255 255 255″
“ButtonLight”=”212 208 200″
“ButtonShadow”=”128 128 128″
“ButtonText”=”0 0 0″
“GradientActiveTitle”=”166 202 240″
“GradientInactiveTitle”=”192 192 192″
“GrayText”=”128 128 128″
“Hilight”=”10 36 106″
“HilightText”=”255 255 255″
“HotTrackingColor”=”0 0 128″
“InactiveBorder”=”212 208 200″
“InactiveTitle”=”128 128 128″
“InactiveTitleText”=”212 208 200″
“InfoText”=”0 0 0″
“InfoWindow”=”255 255 225″
“Menu”=”212 208 200″
“MenuText”=”0 0 0″
“Scrollbar”=”212 208 200″
“TitleText”=”255 255 255″
“Window”=”255 255 255″
“WindowFrame”=”0 0 0″
“WindowText”=”0 0 0″

Andrew Hosting , , , , ,

RubyMine & Git

April 8th, 2010

In order to get Git working in RubyMine, you’ll need to go into preferences and setup the path for the executable.

Preferences > VCSs > Git

Path to git executable: /usr/local/git/bin/git   (for OSx)

Andrew Development , , , ,

Rails: how to change the header (title) for the validation message

March 31st, 2010

The request was simple – how do you change the header (or title) for a validation message.  Using nested resources, I ended up with a weird message:

3 errors prohibited this page[contact attributes] from being  saved

Not very user friendly.   So, I hit Google, blogs and IRC.  So, here the solution I discovered.

<%= error_messages_for ‘c’, :header_message => “Please correct the errors below:”%>

Since this was part of a fields_for block,  I had to add this to my controller method:

@c = @section.contact

Andrew Development , , , ,

Windows 2003 – Login Screen is Black Except for Logo

March 11th, 2010

So, I had a server that ran out of disk space on the OS partition.  Easy to fix, but when I rebooted the server, the screen was black except for the box that has the Windows logo.  I was still able to login, but I had to guess at field I was on when typing. Well, it seems this is a strange by-product of not being able to save your profile when logging off.

There is a somewhat simple solution, but it requires a working server.

http://support.microsoft.com/kb/906510

Andrew Hosting , ,

Configure Apache with a Server Alias

March 10th, 2010

Notes on setting up apache for multiple web sites:

In the /etc/apache2 directory you have two directories:
- sites-available
- sites-enabled

The sites-available directory contains configuration files for each website.
The sites-available contains links to the configuration file in the sites-available directory.  It does not contain the file itself.

The mistake that is made at times is that *all* configs are placed in one file – default.

So, for a domain name like domain.com you would create a file called domain.com in the sites-available directory with the following:

NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www/domain
ServerName www.domain.com
Server Alias domain.com
</VirtualHost>

you would do:  /ln -s /etc/apache2/sites-available/domain.com /etc/apache2/sites-enabled/domain.com

OR

a2ensite domain.com (from within the sites-available) directory.

finally:  /etc/init.d/apache2 reload

So, in a nutshell — create a file per domain name — use ServerAlias to cover www.domain.com and domain.com.

Andrew Hosting , , , , , ,

Jumping into Ruby on Rails – Part 3

February 5th, 2010

Well, I’ve been working on learning Ruby on Rails for several months now.  The past couple of months, I’ve focused more on my studies and I’m finally feeling comfortable with it.

I thought it would be best to share what I think would be the best way to approach learning Ruby on Rails based on all of my experiences.  So, here are my suggestions

1. Learn Ruby on Rails on Linux or a Mac.

Why?  It’s just easier.  An example to this is getting the MySQL gem installed on Windows – after hours of trying to figure this out, I finally gave up and started to use Linux.  You will spend hours trying to get something to work under Windows and to me that is just wasted time.  And I tried all different kinds of approaches – Cygwin, Instant Rails, etc.

2. Learn Ruby

Here are some suggestion:

Programming Ruby 1.9: The Pragmatic Programmers’ Guide (Facets of Ruby)

Free (if you buy a book) class.

Also, most Ruby on Rails books will give you a sufficient overview to the Ruby language to get started.

3. Expect gaps of informaton

This was a *huge* problem for me.  I started working my way through the Agile Web Development with Rails book, that presents itself as a book  from a beginner to an expert.  Well, I discovered that the book *expects* you know the nuances of Rails.

I’ve looked at a good number of books and found this one to be a great one to start with:

Ruby on Rails Bible

Note:  While the book was published in 2008, it covers Rails 1.2 – which was current in 2005.  So the book is a *bit* dated.  However, it does present itself with knowledge about Rails that other books leave out.  Also, as a co-worker pointed out, the web site for the book is – uh, well – broken.

So, specifically, as most Railists know – RoR is convention over configuration – and what I find missing in most books is a good explanation of the conventions.

4. Watch some screen casts:

Free

Railcasts

TeachMeToCode.com ** check out the Flitter tutorial

Paid

PeepCode ** $149 a year – has tutorials on Ruby, Rails, and much more!

Well, that’s my advice.  Let me know if you have any suggestions!

Andrew Development , , ,

Error installing libxml-ruby

February 1st, 2010

So this:

sudo gem install -r libxml-ruby

Gives you this:

ERROR:  Error installing libxml-ruby:
ERROR: Failed to build gem native extension.

/usr/bin/ruby1.8 extconf.rb
checking for socket() in -lsocket… no
checking for gethostbyname() in -lnsl… yes
checking for atan() in -lm… no
checking for atan() in -lm… yes
checking for inflate() in -lz… yes
checking for iconv_open() in -liconv… no
checking for libiconv_open() in -liconv… no
checking for libiconv_open() in -llibiconv… no
checking for iconv_open() in -llibiconv… no
checking for iconv_open() in -lc… yes
checking for xmlParseDoc() in -lxml2… no
checking for xmlParseDoc() in -llibxml2… no
checking for xmlParseDoc() in -lxml2… no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
–with-opt-dir
–without-opt-dir
–with-opt-include
–without-opt-include=${opt-dir}/include
–with-opt-lib
–without-opt-lib=${opt-dir}/lib
–with-make-prog
–without-make-prog
–srcdir=.
–curdir
–ruby=/usr/bin/ruby1.8
–with-iconv-dir
–without-iconv-dir
–with-iconv-include
–without-iconv-include=${iconv-dir}/include
–with-iconv-lib
–without-iconv-lib=${iconv-dir}/lib
–with-zlib-dir
–without-zlib-dir
–with-zlib-include
–without-zlib-include=${zlib-dir}/include
–with-zlib-lib
–without-zlib-lib=${zlib-dir}/lib
–with-socketlib
–without-socketlib
–with-nsllib
–without-nsllib
–with-mlib
–without-mlib
–with-mlib
–without-mlib
–with-zlib
–without-zlib
–with-iconvlib
–without-iconvlib
–with-iconvlib
–without-iconvlib
–with-libiconvlib
–without-libiconvlib
–with-libiconvlib
–without-libiconvlib
–with-clib
–without-clib
–with-xml2-config
–without-xml2-config
–with-xml2-dir
–without-xml2-dir
–with-xml2-include
–without-xml2-include=${xml2-dir}/include
–with-xml2-lib
–without-xml2-lib=${xml2-dir}/lib
–with-xml2lib
–without-xml2lib
–with-libxml2lib
–without-libxml2lib
–with-xml2lib
–without-xml2lib
extconf failure: need libxml2.

Install the library or try one of the following options to extconf.rb:

–with-xml2-config=/path/to/xml2-config
–with-xml2-dir=/path/to/libxml2
–with-xml2-lib=/path/to/libxml2/lib
–with-xml2-include=/path/to/libxml2/include

So, do this:

sudo apt-get install libxml2-dev

And this again:

sudo gem install -r libxml-ruby

Andrew Development , , , , , ,

Free IRC client for Mac

February 1st, 2010

The one thing that I miss about Linux and Windows is the number of quality Open Source projects there available.  I’m all about spending money for software.  Programmers need to eat too.  But if I’m spending money, I would like a little support.  And as I was researching a few IRC clients – most wanted money – little talked about what they offered for support.  Not to mention – some haven’t been updated in years.

So, I came across this product – LimeChat.  At least it gets me to the point where I can ask what everyone recommends.

I’ll post more info later, if I decide to switch to another product or let you know how this one is working out.

Andrew Technology News , ,