Tips 'n Tricks

Insanely easy tabbed web pages with Prototype

I came across this today when trying to find an easier way to present a six-part form in a Rails project - a tabbed interface system built upon Prototype (an integral part of Rails). Called Control.Tabs it makes tabbed interfaces a synch to do: simply add an unordered list containing links to the blocks containing your to-be-tabbed content, and add a line of JavaScript to start the ball rolling - that's it!

Tags: 

Two most important things for PHP development

After having developed in PHP for many years I've realized that the two most important things a developer can do are:

Those two simple changes will greatly help reduce problems in your code. Now to just get all OSS developers to do the same...

Tags: 

Making a form reset button in Rails

Rails doesn't have reset_tag to automatically make a form reset button, instead you have to take a slightly different route. To make a form reset button in Rails you simply do this:
[source:ruby]
< %= submit_tag("Start Over", { :name => 'reset', :id => 'reset_button', :type => "reset" }) %>
[/source]
which will create the following:
[source:html]

[/source]

Tags: 

Strip HTML in any string in Ruby

A little code snippet to let you remove HTML from any string in Ruby:
[source:ruby]
class String

# remove all HTML tags from the source string
def strip_html
self.gsub(/< \/?[^>]*>/, "")
end

end
[/source]
Then to run the code just do this:
[source:ruby]
blurb_html = "

Thanks for visiting our site.

"
blurb_text = blurb_html.strip_html
[/source]

Tags: 

Pages

Subscribe to Tips &#039;n Tricks