Hi, this blog is no longer maintained, my new blog is here

Ruby On Rails and a Conning Israeli entrepreneur

Rails Tip: AR eager loading and :select

The AR::Base.find support the options of :include (for adding associations as JOINs in the select) and :select (which pinpoints the columns you wish to select.
For some reason, it is impossible to do them both toghther for example

Article.find(:all, :include => :author, :select => 'authors.name')

This line will raise an exception.
Luckily, there is the select_with_include gem which enables this feature!

first, install the gem

gem install select_with_include

next, require it in your environment configuration file (or in environment.rb)

require 'include_with_select'

Now, you can use the :select option, remembering to use the table name even if a column name is not unique.
There is a single fault back, in case you want to select all the table columns, you need to write them all, one by one. yeah, it sucks.

Restful Web services gem

i recently read at John Nunemaker's blog about a gem he wrote for simplifying the consumption of REST web services.

Read more about the HTTParty Gem

Rails Tip: URLs ending with .html

This is not a must by all means, just for the hack of it.

add to ApplicationController

def default_url_options(options)
{ :format => 'html' }
end


and you don't need any routes.rb changes.

Rails Tip: image_tag, SEO Optimization

when you use rails's image_tag, by default it sets the HTML attributes of alt and title to the filename of the image. so for

image_tag 'dscn0001.jpg'

will produce the following html something like that

<img src="images/dscn0001.jpg" alt="dscn0001" />


the alt attribute for image tag is meant to explain the content of the image in case the actual image was not found, or for non-graphic browsers.

The default value for the alt attribute should not be used, unless the file name does not really supply information about the image. my suggestion is to use the :alt option in the image_tag helper.

important: do not attempt to use the alt for keywords heaping ('elad-rails-blog-ruby.jpg'), this will not help you in your SEO.

Ruby On Bells

This one is great.
some kind of musical instrument that plays random midi tracks according to a ruby script.
here it is:




Ruby on Bells -- RAD Madrona Fork from jd barnhart on Vimeo.

Unveiling the new startup

I am currently up to an exciting new skeem, me and some of my fellow programmers are working for some quiet time on an amazing, innovative music related startup.

What is it about?


Sorry, can't tell ya yet, hold on and don't be so indomite. :)

What am i doing there?


I am 99.5% responsible for the server side (yap, Ruby on Rails!),what seems to be emerging as my finest work. Barak Edry which helped my on Pdfetch.com and worked with me on Creopolis is busy working on the GUI for both the client and the server (yaii, no views for me... i think) and since Ohad Asulin is our Oracle-ninja-C++-shark and therefore too busy to help me on Rails, i was left responsible for the server side. no sweat :)

OK, but you didn't tell us nothing yet


Right, and i am not going to... just wait and see.

When?!


Soon, every on who is playing on ANY kind of instrument, please e-mail me and you'll be notified as sooooooooonn as the public beta goes out.

more on the secret-amazing-startup to come.

Stand Alone ruby on rails application

Ok,
I Don't really know if anyone has ever done this before, but after viewing some unrelated posts regrading ruby and rails, i succeed in creating a stand alone ruby on rails application.
By saying stand alone, i mean you can copy your application to a usb driver, and start your mongrels anywhere you want!.

i wrote some scripts to setup what the application needs prior to loading, and got it running in no time.

i succeeded doing this with rails 1.2.6 so far, but i don't see any reason why i should not do it with 2.0/1.

now my offer goes a little of something like this, if you will come up with an idea how to make me (and you :) ) some money with this new trick, i'll give up 45%.

start thinking :)

Working in the USA

In 3 weeks i am moving to Florida (yeah, i heard everything everyone has to say) and i am currently looking for a job (Rails related of course).

here is my resume, don't be shy...

Ruby on Rails Screen Casts (rated R :) )

I came across during my never-ending quest for Rails and Ruby related websites, in this cute site (re-design, fast) at Ruby Plus.
They composed over 90 (to this day) screen casts about ruby and rails, including some Rails 2.0 roundups, Ruby metaprogramming and so on.

use it, bookmark it, watch it. (and get the feed too :) ).

why i hate Adsense

As it should be clear already, i am the owner of Pdfetch.com. just until the recent facelift, i used Google's Adsense as my ad operator.

and i did an honest mistake.

i copy-pasted a snippet right above the adsense script, which contained the words "click here".

Google didn't like it so much, and sent me an email which says that i violated the usage terms of Adsense by forcing users to click on ads and they will block my site from using Adsense if i will not remove this phrase in 3 days.

WHHHATTT?

lucky me, i saw this message 2 days after my ultimatum was over (they give you 3 days to complay.... mmmm... some counter-terrorist are consulting Google? :) ). anyway by the time i saw this message and begged them to let me remove this error and get back my ads and explaining them what really happaned,
they replied by saying that the will not allow my to use it anymore on Pdfetch.com

real thanks.

that's why i like amazon now :)

Rails and Oracle, new blog

Hi all,
I am happy to announce that Oracle On Rails, the too-much-anticipated blog from Ohad Asulin about working with Oracle and Rails, Ohad is one of my colleagues and is an excellent Oracle-Ninja, i strongly advice going up on this one (and generally move to Oracle for large scale applications),
you might really like to hear what this guy has to say.

Working with Rails mixup

Uhhh, what can i say..... i am stupid.


i tried to access my account at workingwithrails.com and i forgot my password.
PAUSE
Now i will explain what happend as simple as possible (for you all to laugh at me real good).

Smart:
"oh goodddie, a reset password page!".
very very VERY stupid:
"mmm, i need to fill in the email i registered with, oh it's .. good, it sent me the new details"
after 5 seconds when i realized that i can't read messages from that box.
"oh men!!!!!"

Short and less annoying version for what i did:
Gone to the reset password, reseted password and sent the new details to an email account that i don't own anymore and belongs actually to one of my ex-employers.


damn,
hope to get my account back with the help of WWR support.
and i don't even remember why i wanted to login in the first place :)


PDFetch facelift!!!!

Pdfetch.com was just facelifted al little bit, i was really unhappy for some reason from the previous design, so i did about a 2-hour-fest to do it in another way.

i switched my ad system from Adsense to the Amazon affiliate system, i think it will be more rewarding.




Finally Decided: JQuery, not Prototype

JQuery (for those of you just landed from Mars) is an unobtrusive javascript framework. read more at the JQuery home page.
jQuery supports Behavior driven development and is based on traversing HTML documents by CSS Selectors.
vs.
Prototype,
Prototype is also JavaScript library for Class driven development which makes life easier working with JavaScript. Prototype library has a good support in Ruby on Rails via helper functions and is basically well embedded in.

i decided to try to match both of these libraries (and dojo for the matter of fact, but the project was halted), and here are my conclusions.


  • BDD


    JQuery is very similar to CSS by assigning the HTML element behaviour out-side the HTML, so it is generally more adequate for MVC.
    for ex:

    $(element).click(function() {
    alert("warning");
    });

    simple.

  • Chaining
    Chining methods is as simple as ruby. period

  • CSS Selectors

    Since JQuery is based upon CSS, you can access any element by it's CSS path, and avoid these annoying pesky ID's you have to put using Prototype.


for some more comparisons, visit the Ajaxian article

Finally:
Jquery and prototype are both great. For me, i prefer JQuery since it's approach appeals to me more than Prototype's, Although prototype is kinda Rubish and has inbound support from Rails, JQuery is still cleaner to me.
Did someone said JQuery to Rails integration?

Ruby On Rails Developer Salary in the US


the graph is right here


Data Provided by of simplyhired.com, a search engine for jobs.

As i can see, $86,000 per year, that makes it about $7,100 USD a month, which is just a little more than what a super-rails ninja can get here in Israel, probably more for a short period projects.

how come?


The Web Ask eizesus.com

Subscribe

    follow me on Twitter

    Twiters Around

    About Me

    My photo
    I am a web developer for more than 9 years, managed, cried, coded, designed and made money in this industry. now trying to do it again.

    Labels