Posted on May 28, 2007
time_select is a nice little rails helper that generates dropdown lists for populating time fields, like this:
However, it can get a bit messy for users when they come to use the thing, displaying every minute from 1-60 like this:
You can dress it up nice though by using the :minute_step option. Setting it to 15 just lists the options 0, 15, 30 and 45 like this:
<%= time_select :gig, :doors_open, :minute_step => 15 %>
Filed under: Ruby on Rails |
Posted on May 28, 2007
I'm just starting out with Rails, and making some
ridiculous mistakes along the way.
One of my mistakes was to basically copy the same layout for each controller, not realising that there's such a thing as
application.rhtml.
Application.rhtml allows you to create a global template for the whole site. The problem comes when you want to include controller specific
bits on the page (like a side bar).
A trick I used (and I'm sure there's probably a million better ways of doing this) is to put a partial in the application.rhtml that you know will be used in the controllers.
For example:
application.rhtml
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<title>Your application</title>
</head>
<body>
<div id="left">
<%= render :partial => 'sidebar' %><br/>
</div>
<div id="main">
<%= yield :layout %>
</div>
</body>
</html>
Then in your controller view folders, include a _sidebar.rhtml partial like this:
_sidebar.rhtml in views/user
This is the User Controller Sidebar
<%= link_to "logout" %>
_sidebar.rhtml in views/admin
This is the Admin Controller Sidebar
<%= link_to "Add User" %>
<%= link_to "Remove User" %>
This way you can have a global layout, but also unique side bar details.
Filed under: Ruby on Rails |
Posted on May 27, 2007
So, I started installing Capistrano yesterday using:
gems install capistrano
Annoyingly, the net-ssh dependency failed with the hideous error message:
ERROR: While executing gem … (Zlib::BufError) buffer error
This seems to only happen on windows - and there doesn't seem to be any documentation on how to fix this.
Thankfully, you can fix this problem by upgrading your RubyGems install using
gem update --system
I then installed Capistrano with no probs!
Filed under: Ruby on Rails |