There are a lot of great helper methods in rails, and I need to remember to use more of them, one I over looked for a long time that I have found useful is link_to_if <%= link_to_if logged_in?, “#{}”, :controller => ‘items’, :action => ‘show’, :id => item %> replaces the much longer and more verbose: <%- if logged_in? %><%= link_to , “#{}”, :controller => ‘items’, :action => ‘show’, :id => item %><%- else %><%= %><%- end %> I like being able to replace five confusing lines with one single simple solution. The link_to_if helper writes a link if the condition is met, otherwise it just outputs the text that would have been in the link. Very cool. Also if you want to use Ajax forms with multiple submit buttons in Rails, here is the solution. Lastly if you are trying to write a selector and want to make sure the test is returning the html you expect you can add puts @response.body into the test after the page call and see the response. This has been useful to me a few times.

blog comments powered by Disqus
Dan Mayer Profile Pic

I primary write about Ruby development, distributed teams, & dev/PM process. The archives go back to my first CS classes during college when I was learning to write software. I contribute to a few OSS projects and often work on my own projects. You can find my code on github.

Twitter @danmayer

Github @danmayer