About concept47

Ruby/Rails/Jquery/MySql/PostgresSQL hacker. Wannapreneur. Love to build beautiful things.

(98)Address already in use: make_sock: could not bind to address 0.0.0.0:443

I ran into this problem after I installed mod-rails on a cent OS server.

To get my changes to take … I kept running

httpd -k graceful

and it kept working until, all of a sudden, it didn’t.

This was the error I got

[XXXX@XXXXXXXXX]# httpd -k graceful
httpd not running, trying to start
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:443
no listening sockets available, shutting down
unable to open logs

argh!

Then I found this marvellous blog posting on how to fix the “Address already in use: make_sock: could not bind to address – Apache – HTTPD Error”

Here is what I did. (click to enlarge)

worked like a charm too.

Things that suck about your MacBook Pro that no one will tell you about

I have a Core Duo model and am running windows (w/ bootcamp), so some of this stuff probably doesn’t apply but …

1. The hard drive is painfully slow. When you go to delete something, you can sit there for a good 5 seconds before the delete dialog is gone

2. You can only run an external 2.5 inch hard drive off one particular USB port (the one to the right) … if you put it on any other port, it will not get enough power and be stuck powering up then powering down. Or it will power up and stay fine for a bit, until it suddenly starts experiencing the situation I’ve described.

3. Maximum installable RAM … 2 Gigabytes.
god.

4. While you can get up to 4 hours of power running OS X on the battery … you’ll barely get 2 hours running Windows.

note: This is a late night rant … I love my darling MacBook Pro.

Ruby on Rails gotcha: undefined method `rewrite’ for ….

undefined method `rewrite' for "":String

If you get this error, and the error message is pointing you to a “link_to” call or something similar, then you may be using an instance variable that’s called ‘@url’ too.

This blog post did talk about the problem but it seemed limited to models only. I finally discovered that, in my case, I was using ‘@url’ in the controller for the view where I was making the ‘link_to’ call.

Long story short, if you see this error, comb through your code (models, controllers and views) for any variables that are called ‘@url’  and change them.

Dreamhost now supports mod_rails on their shared hosting plans

Dreamhost now supports the use of mod_rails on their shared hosting plans

The Phusion team contacted me with a working test version of Passenger a couple of months ago and since then DreamHost has been helping out with testing and ironing out lingering deployment issues.  The Phusion team has been very helpful and responsive throughout the process and I think we will see a lot more great things from them in the future.

Now to the important part… how do you use Passenger on DreamHost?

Briefly, all you do is enable the Ruby on Rails Passenger (mod_rails) option for any existing or new web domain in the DreamHost web control panel. When you then point that domain’s web directory to the public directory of an existing Ruby on Rails application it will work automatically.  For more detailed information, check out our Passenger wiki page.

php’s print_r equivalent in ruby on rails

I was going through my google analytics logs today and I noticed that a lot of folks were coming to my site on Google searches for stuff like ‘print_r + ruby on rails‘.

So I figured I’d write a blog post about it, because I’ve had the same problem.

What you’re looking for is ‘inspect’.

If you have an array, hash or object that you want to take a quick-and-dirty look at just type in

objectname.inspect

eg:

posts.inspect

or if you’re in rails just do …

render :text => posts.inspect and return false

and you’ll get an output of the contents of said array, hash or object.

Here is a screen capture of a quick irb session to show you how it works.

print_r equivalent in ruby on rails

I hope this helps.

Gotcha in Ruby for PHP Developers with multiple assignments of array to variables

The more I work with Ruby and Ruby on Rails, the more I begin to understand (though not necessarily agree with) a lot of the vitriol that has been aimed at PHP over the years by developers using other more rigorous languages.

A few weeks back I ran into this little speed bump while working with Ruby on Rails, where I was  trying to do a multiple assignment like this

x = y = z = []

Most seasoned Rubyists will be waving their arms around and yelling “NOOOOOO!!!”
But coming from a PHP background this seemed perfectly okay to me.

Continue reading

Ruby on Rails: How to get the output from an action (render_component_as_string)

This one took a little bit but I finally figured it out …

@xml = render_component_as_string :controller => “quote”, :action => “xml”, :params => {:request_id => 100}

This would run the action “xml” of the controller “quote” and pass the parameter  “100” to it to do so.

Whatever would have been displayed at /quote/xml/100 is now stored in @xml

This allows you get the output from any action …. anywhere, also allowing you to pass parameters to it in the process.

Even better, this actually runs the action and its view (unlike render :action, which just renders the action view).

For more details, go to the Ruby On Rails Manual > Using components

Apache Mod Rails released!!!

After weeks of anticipation , the apache module that allows you to upload your ruby on rails application to the server and have it “just work” has just been released.

I’ve just downloaded the source code from their git repository (git rocks!!) and am trying to see if it’ll install on windows.

Update: It won’t install on windows and there are no plans to ever allow it to (damned Linux elitists!!! :P).

mod_rails released!

Getting rid of duplicate Entries in your MySql database

Thanks for Justin Cook for doing all the leg work on this one.

All you have to do is create a new table from the old one, which filters out the duplicate entries

1
2
3
CREATE TABLE new_table AS
SELECT * FROM old_table WHERE 1
GROUP BY [colum_to_remove_duplicates_from];

so as an example

1
2
CREATE TABLE news_new AS
SELECT * FROM news WHERE 1 GROUP BY [title]; <a href="http://www.concept47.com/austin_web_developer_blog/developers/getting-rid-of-duplicate-entries-in-your-mysql-database/#more-113" class="more-link">Continue reading <span class="meta-nav">&rarr;</span></a>