Rails question: changing individual attribute data

Hi

I've started the tutorials on rails and I've really enjoyed it so far. However, I have hit a bit of a snag. I've looked through the tutorials and the API but I couldn't figure out how to do it.

I'm writing an application to store information on system specifications. One of the things I would like it to do, is to not delete records but instead 'unlink' them(set the id to 0). I know the attributes method allows you to replace all the values but I only want to replace the id value. I messed around with it until I didn't get an error but I still can't get it to work. Help! Help! Any ideas, suggestion, criticisms, abuse; hell, I'll take anything useful at this point.

Here's the code I have so far:

  def destroy
  @system = System.find(@params["id"])
  @system.id = 0
  @system.save
  
  redirect_to :action => "list"
   end

I don't know if this code does anything useful. :slight_smile:

I am running ruby 1.9.0 (2004-03-09) [powerpc-darwin] on MacOS 10.3.7 on a Powerbook G4. Rails is installed via gem:

actionmailer (0.4.0)
     Service layer for easy email delivery and testing.

actionpack (0.9.5)
     Web-flow and rendering framework putting the VC in MVC.

activerecord (1.1.0)
     Implements the ActiveRecord pattern for ORM.

rails (0.8.5)
     Web-application framework with template engine, control-flow layer,
     and ORM.

rake (0.4.12, 0.4.11)
     Ruby based make-like utility.

sources (0.0.1)
     This package provides download sources for remote gem installation

The views are the standard tutorial views. They work fine until I try the code above.

Also, is there a rails book in the works? I would really, really like one. I would pay exorbitant amounts of money for it.

Much obliged,

Sven Schott

P.S. Thank you very much to the fine gentleman who wrote rails. Once I get the hang of it, I will throw Filemaker out the window.

Sorry about the noise. I scoured the API docs and found the answer.

@system['field']="value"

I didn't know it was just a hash. Nice.

Sven

···

On 05/01/2005, at 3:14 PM, Sven Schott wrote:

Hi

I've started the tutorials on rails and I've really enjoyed it so far. However, I have hit a bit of a snag. I've looked through the tutorials and the API but I couldn't figure out how to do it.

I'm writing an application to store information on system specifications. One of the things I would like it to do, is to not delete records but instead 'unlink' them(set the id to 0). I know the attributes method allows you to replace all the values but I only want to replace the id value. I messed around with it until I didn't get an error but I still can't get it to work. Help! Help! Any ideas, suggestion, criticisms, abuse; hell, I'll take anything useful at this point.

Here's the code I have so far:

def destroy
  @system = System.find(@params["id"])
  @system.id = 0
  @system.save
  
  redirect_to :action => "list"
  end

I don't know if this code does anything useful. :slight_smile:

I am running ruby 1.9.0 (2004-03-09) [powerpc-darwin] on MacOS 10.3.7 on a Powerbook G4. Rails is installed via gem:

actionmailer (0.4.0)
    Service layer for easy email delivery and testing.

actionpack (0.9.5)
    Web-flow and rendering framework putting the VC in MVC.

activerecord (1.1.0)
    Implements the ActiveRecord pattern for ORM.

rails (0.8.5)
    Web-application framework with template engine, control-flow layer,
    and ORM.

rake (0.4.12, 0.4.11)
    Ruby based make-like utility.

sources (0.0.1)
    This package provides download sources for remote gem installation

The views are the standard tutorial views. They work fine until I try the code above.

Also, is there a rails book in the works? I would really, really like one. I would pay exorbitant amounts of money for it.

Much obliged,

Sven Schott

P.S. Thank you very much to the fine gentleman who wrote rails. Once I get the hang of it, I will throw Filemaker out the window.