27 Sep '12, 3pm

Don’t Repeat Your Ruby Constants in Javascript

September 27, 2012 Tagged: erb javascript preprocessing rails magic numbers don't repeat yourself Comments (View) Don’t Repeat Your Ruby Constants in Javascript Constants help us avoid Magic Numbers and repeated code, which violates the DRY principle. Recently, I needed to count down the the remaining characters in a text field. I limited the length of the attribute using a constant: class Event < ActiveRecord::Base NAME_MAX_LENGTH = 70 validates :name, length: { maximum: NAME_MAX_LENGTH } # ... end Then I repeated myself in the JavaScript: # app/assets/javascripts/countdown_event_name.js var max = 70 “This is a nasty scenario - I’ve got the same value in two places!”, says I. How else could I access the constant more cleanly from my Event model in the JavaScript? Answer I discovered you can use ERB in JavaScript if you change file extensions and trigger preprocessing like...

Full article: http://robots.thoughtbot.com/post/32392361476/dont-repeat...

Tweets

I Don’t Make Mistakes. I Use C I like the title :)

electronicdesign.com 26 Sep '12, 6am

I was recently at Design East in Boston. The show is changing with more of a slant towards software and hardware tools. I ...

This is a big issue: Women vets still don’t cal...

stripes.com 27 Sep '12, 11pm

Women vets still don’t call themselves veterans By Leo Shane III Published: September 27, 2012 Veterans Affairs Undersecre...

Ruby Weekly #112 is now out:

rubyweekly.com 27 Sep '12, 12pm

Issue 112 - September 27, 2012 Featured Turbolinks: Rails 4 to Get Ajax-based Page Loading by Default David Heinemeier Han...

Blog: DON’T JUST THINK OF YOUR SONS, Think Of A...

anwaribrahimblog.com 27 Sep '12, 4am

Opposition Leader Anwar Ibrahim lashed out at former Mahathir Mohamad, accusing the latter of putting the business interes...

Don’t Outsource SEO If …

Don’t Outsource SEO If …

searchmarketingstandard.com 04 Oct '12, 10pm

For a large business, it may make sense to have a dedicated SEO Specialist on the team so that SEO is the focus of their j...

Are Marketers Ruining Social Media? 3 Tips to Ensure You Don’t

Are Marketers Ruining Social Media? 3 Tips to E...

networksolutions.com 27 Sep '12, 1pm

Are Marketers Ruining Social Media? 3 Tips to Ensure You Don’t September 27th, 2012 :: Monika Jansen Are marketers ruining...

how to add a column name with value to the link...

stackoverflow.com 04 Oct '12, 8pm

I am calling a dialog pop up box by the link_to method in ruby on rails. <%= link_to pro_generic_lookup_data_path("Enr::Rd...

Injured and can't run? Don’t let it set you back. These alternatives will keep you in the game:

Injured and can't run? Don’t let it set you bac...

triathlon.competitor.com 04 Oct '12, 5pm

Research suggests that nearly half of all runners experience an injury every year. That’s a whole lot of harriers sentence...

Unholy Rails: External Scripts, jQuery Plugins,...

rubyflow.com 26 Sep '12, 8am

Unholy Rails: External Scripts, jQuery Plugins, and Page-Specific JavaScript Posted by DanielKehoe on September 26, 2012 —...

Many female veterans still don't see themselves...

stripes.com 27 Sep '12, 7pm

Women vets still don’t call themselves veterans By Leo Shane III Published: September 27, 2012 Veterans Affairs Undersecre...

On JavaScript Ninjas, Ruby on Rails Rockstars, ...

37signals.com 02 Oct '12, 5pm

Watched by David on July 26 2012: Vooza is finding their JavaScript Ninjas, Ruby on Rails Rockstars, and HTML Wizards thro...

Automatically reload the browser for Javascript...

robots.thoughtbot.com 29 Sep '12, 8pm

September 29, 2012 Tagged: backbone coffescript guard jasmine javascript testing howto recipe Comments (View) Automaticall...

In the national conversation, some kinds of tal...

yawningbread.wordpress.com 30 Sep '12, 10am

The second hurdle is the unwillingness to discuss fundamental rights issues and paradigmatic straitjackets. When criticism...

Yasiin Bey Speaks On Palestine, Drops New Muhammad Ali Louis Vuitton Ad [VIDEO]: Over the weekend, the dynamic d...

Yasiin Bey Speaks On Palestine, Drops New Muham...

hiphopwired.com 26 Sep '12, 5pm

Over the weekend, the dynamic duo of Yasiin Bey and Talib Kweli – collectively known as Black Star – rocked Club Nokia in ...

I'm hiring! Web App Developer (Ruby and Javascr...

linkedin.com 05 Oct '12, 11pm

Javascript is 49% of our code base – and it’s all raw – you need to be comfortable and effective outside of JS frameworks ...