News for hackers. Stuff that matters.
Re:Offer HN: Help with Ruby on Rails by erikpukinskis on Wednesday October 27, 2010 @09:45PM (#1841330)
As for (2), yes you can. Let's say you have a form that lets you update the status of your cat and your dog:

    # config/routes.rb
    map.resource :pets, :member => [:show, :update]

    # app/views/pets/status.html.haml
    - form_tag update_pets_path do
      .cat_fields
        - fields_for @cat do |f|
          = f.text_field :status
        = submit_tag
      .dog_fields
        - fields_for @dog do |f|
          = f.text_field :status
        = submit_tag
  
    # app/controllers/pets_controller.rb
    def show
      @cat = Pet.find_by_species("cat")
      @dog = Pet.find_by_species("dog")
    end

    def update
      ["cat", "dog"].each do |species|
        pet = Pet.find_by_species(species)
        pet.update_attributes(params[species])
      end
    end

There are no comments on this comment yet.