Tuesday, December 11, 2012

Windows 7 Mongrel Rails Port 80 Permission Denied Bind(2)

Alright, just spend an annoying amount of time on solving this issue, and although this issue can manifest itself for many reasons - I'll share my specific reason and hopefully it will help others.

The specific error from the mongrel logs is


** Starting Mongrel listening at 0.0.0.0:80
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mingw32/bin/../lib/mongrel/tcphack.rb:12:in `initialize_without_backlog': Permission denied - bind(2) (Errno::EACCES)


The issue is, I was trying to deploy a rails app that's run using mongrel on Port 80. This has been successfully deployed to many sites running Windows 7 Pro, and I was trying to deploy it to Windows 7 Home Premium. At first I thought the operating system was the issue, but it definitely wasn't.

After googling around for awhile, I found a lot of posts linking it to IIS conflicts. But the thing is, I didn't have IIS running on my machine - no "World Wide Web Publishing" service running - or at least not in its entirety.

You see - what the issue was - was that I do some .Net development on this computer - and at one point for testing purposes, I installed IIS Express. Yes, IIS Express was the culprit. The hard part was, is that IIS Express shows up as a differently named service - it's called "Web Deployment Agent Service".

I launched up Services.msc, disabled this service- and bam, things were up and running.

Hope this helps some peeps.

Tuesday, July 31, 2012

BiteSite.ca launches

Hey everybody!

I just launched my new Web Design and Web Development business, BiteSite.ca. We're based in Ottawa Canada and are here to build web sites and web applications for all sorts of customers including

  • Small to Medium Businesses
  • Individuals
  • Wedding Couples
  • Event Organizers
  • and more!
We also provide Video and Photography services. Anyway, check us out at www.bitesite.ca!

Friday, June 15, 2012

Rails 3.0 and JQuery-UJS Rails.js

So there are a bunch of posts and a great Railscast about using Unobtrusive Javascript and Rails.
The rails cast even gives a great section about using JQuery instead of Prototype - and how there's a specific rails.js for JQuery. But I definitely had issues getting this going until today - so hence the blog entry and a mistake perhaps that is not published yet on other posts.

First some background.

So Rails 3.0 and below used to use a Javascript library called Prototype by default. This javascript library (like JQuery) allowed for some powerful javascript functionality with little code. However, I'm a JQuery guy, so I opted to use JQuery.

So the deal is, in my layout, I used a javascript_include_tag for JQuery so I could start using JQuery all over the place in my app. The issue? As soon as you use JQuery instead of Prototype, a bunch of stuff starts breaking - the biggest most obvious culprit? The Delete link.

In scaffolding or even in your own coding, you may write a link that looks like this:

<%= link_to "Delete", @resource, :method => delete, :confirm => "Are you sure? %>

Now the thing to know about this is - this generates a link with specific attributes. And its those attributes that identify it as a special link. What identifies it as a special link? rails.js

Rails.js will look at links like this - dynamically create a form around this link, and then submit it when you click on the link. That's why the replacing this with "button_to" solves the problem in one way. Because button_to creates that form for you, and doesn't rely on rails.js to create that form.

Now the problem is - the default rails.js that's included in Rails 3.0 and below relies on Prototype. So if you switch to using JQuery - the default rails.js isn't going to work.

This is where the Railscast gives a good explanation to hit up the jquery-ujs github account (just Google jquery-ujs and you'll find it), and download the rails.js that exists there.

In you application (probably) you're layout, if you use a javascript_include_tag to include both JQuery, and the jquery-ujs version of rails.js - you should be good to go.

(and believe me if you do the steps right - you will be good to go).

I, however, did not do the steps correctly.

I followed the logic and followed the instructions and still things were breaking.

What did I do wrong?

Something really stupid. I downloaded the jquery-ujs/rails.js file incorrectly. I was using my browser and just right-clicked and "Save link as...". The problem is - I wasn't downloading the raw source code file which is what you need. The best way to do this is when in Github, jquery-ujs, click on src, then click on "rails.js". Then click on the "RAW" button to grab the actual source file. This was the key.

So just in case anybody else runs into this issue, make sure the rails.js file you're getting is the true raw source code file.

Btw, for Rails 3.1 and above - you don't have to worry about this. Rails 3.1 made JQuery the default javascript library (instead of Prototype) - and as an added bonus, they by default include the "jquery-rails" gem in the Gemfile. This gem contains both JQuery and the Jquery-ujs Rails javascript files and it automatically serves them up through the asset pipeline.

So all the information was already out there - I just made a stupid mistake that maybe some of you might run into so I thought I'd blog about it.

Monday, May 28, 2012

Namecheap E-mail Forwarding to GMail

Alright, so I've seen several posts of this and experienced it myself and I couldn't seem to find an answer. Luckily, in mucking about I seemed to stumble about a solution that has worked thus far.


The Issue:

The issue was that if you registered for a Namecheap domain, and wanted basic e-mail forwarding, it didn't seem to work with GMail. No, I'm not talking about using Namecheap's e-mail servers, no I'm not talking about Google Apps for business, I'm talking basic forwarding of one e-mail address to another. For example, forwarding info@mydomain.com to myaddress@gmail.com. For some reason, it would work with e-mail service providers like Hotmail but not with GMail - and GMail really is my favourite.


The Solution:

Alright, the solution that has worked for me seems to lie in assigning an e-mail alias in GMail. But the only way you can do that is temporarily forward your e-mail to a non-GMail account.

So what you end up doing is temporarily forward your domain e-mail address to a non-GMail account, and then add an alias to the GMail account (which sends a verification e-mail to your non-GMail account). Once the GMail alias has been verified, now you can set your Domain to forward to your GMail account.

Here are the steps:

There are 3 accounts we're dealing with:

  • a. Domain account - in our example "info@yourdomain.com"
  • b. Non-GMail Account - in our example "me@hotmail.com"
  • c. GMail Account - in our example "me@gmail.com"


Register Your Domain and setup e-mail forwarding to non-Gmail Account

  1. Hit up www.namecheap.com and register your domain.
  2. In your domain settings, click on "E-mail Forwarding"
  3. Setup an entry to forward "info@yourdomain.com" to non-GMail account like "me@hotmail.com".


Test E-mail

  1. Send an e-mail to "info@yourdomain.com", you should get it in your hotmail.


Setup your GMail account

  1. Log into your gmail account, and go to settings.
  2. Under Accounts and Import, look for "Send mail as..."
  3. Add your "info@yourdomain.com" account.
  4. This will cause GMail to send a Verificaiton e-mail to "info@yourdomain.com" which should end up in your non-GMail account "me@hotmail.com".
  5. Enter the verification code
  6. Make "info@yourdomain.com" your default account.
  7. GMail is now setup send mail as "info@yourdomain.com" and for some reason this unblocks the namecheap forwarding.


Switch Forwarding E-mails to GMail Account

  1. Now that GMail doesn't block namecheap anymore, switch your e-mail forwarding entry "info@yourdomain.com" to forward to "me@gmail.com"

Sunday, April 29, 2012

Gitting to Know You

Hey everybody,

just a quick note, I've started some tutorial videos on GIT. If you're new to Git, check 'em out and spread the word.

http://www.caseyli.com/gittingtoknowyou

Saturday, December 24, 2011

JQTouch and Google Maps API Rendering Issues

Really quick one today. Today I implemented Google Maps into my JQTouch webapp using the Google Maps Javascript API V3.

Seemed easy enough except I was having a lot of rendering issues with the Google Maps (lots of gray areas where maps weren't rendering).

The key is, the Map constructor for Google Maps takes into account a div and renders a map in it. Let's call that the "map-div".

The issue was that I was using Javascript to render the map, then I called a jQT.goTo("#mappage") which changed the positioning of the map-div tag where the map was being rendered.

Quick solution: navigate to the page where the map-div is first - then do the Google Maps rendering. In my case, I had to call the jQT.goTo("#mappage") first, then I did my Google Maps rendering. Problem solved. Maps rendered gorgeously!

Friday, December 2, 2011

jQuery AJAX Post to a Rails Create Function

Alright, I was going to do this posting when I discovered my solution, but I got super busy and never got around to it.

Basically the problem I ran into was knowing how to call Rails Create function using JQuery AJAX. There were a few parameters I didn't know about - like what was the URL, what was the type of AJAX call, how did I pass the data etc.

So, my setup was that I had a controller for my sessions and I was using rails "resources" routing to generate the routes for it. The "create" action of the SessionsController required a "session" object that contained an "email" and a "password" and the session was expected to be incoming via the parameters. That is, the SessionController.create was looking for params[:session][:email] and params[:session][:password].

So how do I get all this to happen with an AJAX JQuery call:

$.ajax({
type: "POST",
url: "/sessions",
dataType : "json",
data: { session : { email : var_email, password : var_password } },
success : function(data, textStatus, jqXHR) {
},
error : function(jqXHR, textStatus, errorThrown) {
}
});

The thing that took me a while to figure out was the URL and the type and the data. Probably would have helped if I reviewed my "resources" routing in Rails and also new that you could pass a JSON object to a Rails controller.