Errors using Capistrano
“** [out :: myserver] deploy is not in the sudoers file. This incident will be reported.” — Solution is here.
“** [out :: myserver] deploy is not in the sudoers file. This incident will be reported.” — Solution is here.
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
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:
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
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!
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
Ruby on Rails on Windows Vista :: Getting error “The application has failed to start because sqlite.dll was not found.”
Solution:
Copy sqllite3.dll to a directory that is in your %path% variable.
I’ve update
d my instructions on preparing a VPS for Ruby on Rails, after running into a few issues. I *think* that installing gems through apt-get caused problems when I was trying to install a CMS called Radiant.
So, here are the new instructions:
apt-get install ruby irb rdoc libopenssl-ruby ruby1.8-dev
apt-get install sqlite3 libsqlite3-ruby1.8wget http://rubyforge.org/frs/download.php/60718/rubygems-1.3.5.tgz
tar xzvf rubygems-1.3.5.tgz
cd rubygems-1.3.5/
ruby setup.rbln -s /usr/bin/gem1.8 /usr/local/bin/gem
ln -s /usr/bin/ruby1.8 /usr/local/bin/ruby
ln -s /usr/bin/rdoc1.8 /usr/local/bin/rdoc
ln -s /usr/bin/ri1.8 /usr/local/bin/ri
ln -s /usr/bin/irb1.8 /usr/local/bin/irbgem -v
gem update –system
gem install rails
To install MySQL:
apt-get install mysql-server libmysql-ruby1.8 libmysqlclient15off mysql-client-5.0 mysql-common mysql-server-5.0 mysql-server-core-5.0
The instructions have been updated here.
Here are the steps I use to install Ruby on Rails on my VPS (www.rackspacecloud.com) a Ubuntu 9.04 (jaunty)
apt-get update
apt-get upgrade
apt-get install build-essential
aptitude install ruby1.8-dev ruby1.8 ri1.8 rdoc1.8 irb1.8 libreadline-ruby1.8 libruby1.8 libopenssl-ruby sqlite3 libsqlite3-ruby1.8
aptitude install ruby build-essential libopenssl-ruby ruby1.8-dev
apt-get install sqlite3 libsqlite3-ruby1.8
apt-get install rubygems
ln -s /usr/bin/gem1.8 /usr/local/bin/gem
ln -s /usr/bin/ruby1.8 /usr/local/bin/ruby
ln -s /usr/bin/rdoc1.8 /usr/local/bin/rdoc
ln -s /usr/bin/ri1.8 /usr/local/bin/ri
ln -s /usr/bin/irb1.8 /usr/local/bin/irb
export PATH=$PATH:/var/lib/gems/1.8/bin
gem install -v=2.3.4 rails
gem install rubygems-update
update_rubygems
gem install rails
gem install -v=2.3.4 rails
export PATH=$PATH:/var/lib/gems/1.8/bin
So, I’ve made the decision to write my apps in Ruby on Rails. Now what?
Here are the books I chose to start:
Agile Web Development with Rails, Third Edition
Programming Ruby 1.9: The Pragmatic Programmers’ Guide (Facets of Ruby)
Introduction to Ruby on Rails – I highly recommend the class. It gives you an opportunity to ask the “do I understand this correctly?” or “compared to C#, is this the same?” type of questions.
Learning Rails – a great site with resources on learning Ruby.
PeepCode Screen Casts -tutorials on Ruby.
Ruby Mine – an IDE for Ruby. (I’m downloading to try it out and will be writing a review on it later.)
So, I’ve set aside a budget for all of this and one thing that I included was a VPS (virtual private server). Now, I know what you’re thinking, isn’t this a bit overboard for learning RoR? Perhaps, but I found a provider that offers cloud hosting for as little as $0.015 an hour. Roughly, that’s about $10 a month.
My production VPS is hosted at another site, which I pay about $30 a month. It hosts several blogs (including this one) and my email server.
For the past 20 years, I’ve covered quite a bit of ground in technology – from help desk to management. Through the various positions I’ve held, I’ve never been a programmer full-time. However, in all of the positions I’ve held, I’ve always managed to do some programming to improve processes.
Early on, I wrote a program to track Help Desk calls in COBOL on a Prime 6550. I’ve also wrote a utility to export specific emails from Outlook and route them to be printed automatically and stored. Additionally, I’ve developed utilities to assist in the management of systems, specifically to accommodate a uniquely designed system.
More recently, I’ve been thinking about developing some sites based on ideas that I’ve been floating around for some time. For several months, I’ve debated which technology to use for the development. .Net? Perl? Java? PHP? ROR?
It is commonly known that Nashville is a .Net city, so at first I chose the .Net technology. I headed down the path, got the right books, watched the right web casts, but I stalled on three items.
First, the cost of deployment. While I know there are solutions that offer cheap hosting for .Net, there is a point at which an application cannot scale using cheap hosting and would then require some what of an investment (specifically SQL Server).
Granted you could use alternative database servers. However, this deviates from all of the tutorials and books that I’ve explored. Keep in mind, I am not a full time programmer, so for me all of this is done in my spare time. So, using an alternative database adds complications that I would have to sort through.
Finally, I’m taking a “slow cooker” approach on these apps. I’m taking my time developing them – learning as I go – and a few are more of a hobby than a business.
Second, too many distractions. For example, what is the best way to write to the database? Use SPs? Use in-line SQL? Use LINQ? Given there are a bunch of people with opinions on each of these approaches, I have no way of knowing what is best for what I’m doing. I spent more time reading articles than planning the design of the site.
Third, the books I just purchased are out of date! (I exaggerate, of course). So, I started looking at ASP .NET 2.0 a while back. Then 3.0 came out and then 3.5. So, do I use LINQ? WPF? WCF? WF? MVC? Again, keep in mind, I’m not a full time programmer, so I had a difficult keeping up.
So, I decided to choose Ruby on Rails. Why? I just finished working on a project involving LAMP and I really enjoyed it. Second, I appreciate the convention over configuration aspect. Third, this allows me to spin up these apps at a low cost over time.
In my next post, I’ll share with you the materials I’m using to learn Ruby on Rails.