Results tagged “ruby” from dead prophet

RubyOnRails_HomePage.png

I have a question regarding link_to helpers.  When do you use them and when do you not use them.

Example.
Use basic HTML:

<a href="/foobar/10">FooBar</a>                                               
or instead use a helper:

<%= link_to "FooBar", { :action => "foobar", id => 10 } %>                    
Both return the same result.  Is it strictly a preference?  I find the syntax of these helpers so forgettable and non-intuitive.  I'm not the smartest kid in the class, but every time I need to add a class name to the link so that the CSS style takes affect, I find myself googling "How do I add class names to link_to calls".  It's a pain.  It's my pain, but it's a pain.

Also, what about link_to_remote?  What if I have a loop in my view and I'm outputting 10 or 20 list items that each have the link_to_remote call?  Do I really want the JS function created 20 times?  1 for each call?  

Obviously DHH and his crew of merry men have a reason and a purpose for these helpers, otherwise they wouldn't be there, or at least they wouldn't be called helpers, they'd be called annoyers, but somewhere in our web apps we're going to have to write some HTML code.  Or is there a create_linebreak_here helper that inserts a <br /> for you?

What is the best practice when it comes to these little do-dads?

Resource Links:


Thumbnail image for The Merb Homepage
"Like Ruby on Rails, Merb is an MVC framework. Unlike Rails, Merb is ORM-agnostic, JavaScript library agnostic, and template language agnostic, preferring plugins that add in support for a particular feature rather than trying to produce a monolithic library with everything in the core. In fact, this is a guiding principle of the project, which has led to third-party support for the ActiveRecord, DataMapper, and SequelORMs."

The Django Framework

"Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.

Developed and used over two years by a fast-moving online-news operation, Django was designed to handle two challenges: the intensive deadlines of a newsroom and the stringent requirements of the experienced Web developers who wrote it. It lets you build high-performing, elegant Web applications quickly.

Django focuses on automating as much as possible and adhering to the DRYprinciple."

---

Personally, I like Merb.  I like the colours, I like the design and I think 4 letters are better than 6.  And putting two consonants like "D" and "J" so close together is a cocky play.

Live free Merb.  

Django you can kiss it.


Tags

Find recent content on the main index or look in the archives to find all content.