Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Rails question: changing individual attribute data

Reply
Thread Tools

Rails question: changing individual attribute data

 
 
Sven Schott
Guest
Posts: n/a
 
      01-05-2005
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.

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.



 
Reply With Quote
 
 
 
 
Sven Schott
Guest
Posts: n/a
 
      01-06-2005
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.
>
> 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.
>
>
>




 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ActiveRecord ids differ outside of rails for rails data table? Xeno Campanoli Ruby 1 06-03-2008 06:57 PM
Looking for a way to access ActiveRecord data in a rails app fromanother non-rails app with $SAFE=1 Xeno Campanoli Ruby 1 05-29-2008 12:21 PM
changing individual elements of a char variable owolablo C++ 7 12-03-2006 03:41 AM
problem with char*'s and changing individual chars in it whiteboy C++ 8 09-22-2005 04:22 PM
Changing individual table cell or row borders with CSS news frontiernet.net HTML 6 12-05-2003 03:46 AM



Advertisments