August 3rd, 2005
Test
You can include multiple javascript and css files with:
<%= stylesheet_link_tag 'scaffold', 'master' %>
<%= javascript_include_tag 'prototype', 'effects', 'controls', 'edit' %>
Alternating Row Colors without redundant classes:
#In a helper
def alternate_class
@class = (@class != '') ? '' : 'class="shade"'
end
#In your view
Save values of a multiselect dropdown (ie. Articles belongs to many categories):
#In your controller
@article.categories.clear
@article.categories << Category.find(@params[:categories])
if @article.save
flash[:notice] = 'Article was successfully created.'
redirect_to :action => 'show', :id => @article.id
end
#In your view
<p>
Lets say you had a sidebar in your app, in each view the contents for this sidebar might change. Instead of putting the sidebar code inside every view you could do something like:
#In your _layout_ file
<div id="sidebar">
@content_for_sidebar
</divp>
#In your view(s)
<% content_for('sidebar') do %>
<p>You are now on a really hip page!</p>
<% end %>
Got any quick drops of goodness of your own?
UPDATE: Textpattern is doing weird stuff with my code, either way I code it whether escaping it or not it renders as html code on my live site or in RSS readers. Looking into that now.
Sorry, comments are closed for this article.


Discussion
只需10元,就能让你的广告遍布各个网站! 支持图片/超链发送!支持分类/地域网站发送!
10元,就可能换来意想不到的效果,为什么不尝试下呢! QQ:224549200(注明“广告”)