Skip to main content

Fran

Fran 's Public Library

12 Jun 07

Rails Envy: Ruby on Rails Rake Tutorial (aka. How rake turned me into an alcoholic)

  • Task creation - With every large application you almost always end up writing scripts that you can run from the command line. You might want to clear the cache, run a maintenance task, or migrate the database. Rather than creating 10 separate shell scripts (or one big complex one) you can create a single "Makefile" in which you can organize things by task. Tasks then can be run by typing something like "make stupid" (which runs the stupid task).
23 May 07

Javascript, AJAX and scriptaculous on Rails

  • <%= link_to_function "[Show|Hide]",
    visual_effect(:toggle_blind, :links, :duration => 1) %>
06 Apr 07

Ruby Fleebie » Check for nil and initialize on a single line

    • 1) You can use the if modifier


      1. x = get_some_object if x.nil?  
      2. x ||= get_some_object  

Module: ActionView::Helpers::FormHelper

  • This allows you to add fields from one model in another model really easily and cleanly.
    - draconid on 2007-02-09
  • fields_for(object_name, *args) {|builder.new(object_name, object, self, options, block)| ...}



    Creates a scope around a specific model object like form_for, but doesn‘t create the
    form tags themselves. This makes fields_for suitable for specifying
    additional model objects in the same form. Example:


      <% form_for :person, @person, :url => { :action => "update" } do |person_form| %>
    First name: <%= person_form.text_field :first_name %>
    Last name : <%= person_form.text_field :last_name %>

    <% fields_for :permission, @person.permission do |permission_fields| %>
    Admin? : <%= permission_fields.check_box :admin %>
    <% end %>
    <% end %>


    Note: This also works for the methods in FormOptionHelper and DateHelper that are designed to work with an
    object as base. Like collection_select and datetime_select.

1 - 20 of 311 Next › Last »
Showing 20 items per page

Highlighter, Sticky notes, Tagging, Groups and Network: integrated suite dramatically boosting research productivity. Learn more »

Join Diigo