Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

davenolan http://textgoeshere.org.uk

« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS 

Use rails date_select without activerecord model

// In your view:
<%= date_select('range', 'start_date', :order => [:month, :day, :year])%>


// In your controller:
@start_date = Date.civil(params[:range][:"start_date(1i)"].to_i,params[:range][:"start_date(2i)"].to_i,params[:range][:"start_date(3i)"].to_i)


Credit: http://www.jonsthoughtsoneverything.com/2006/05/21/how-to-access-date_select-without-an-active-record-model/

Using a mutiple collection select form helper with habtm or has many associations in Rails

// where user has and belongs to many roles

# in your view
<%= collection_select :user, :role_ids, Role.find(:all, :order => 'name ASC'), :id, :name, { :selected => @user.role_ids }, { :multiple => true, :name => 'user[role_ids][]' } -%>
« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS