Apr 11

Da ich inzwischen immer mehr mit Ruby on Rails arbeite, brauch ich auch hier mal wieder ne Sammelstelle für gute Tips und Ideen .. und Sachen die ich praktisch finde.

Los gehts mit “:serialize”:



class User < ActiveRecord::Base serialize :preferences
end

user = User.create(:preferences) => { “details” => “full”, “stylesheet” => “old” })
User.find(user.id).preferences # => { “details” => “full”, “stylesheet” => “old” }

Und mit diesem bischen Code kann man ohne Probleme Arrays oder Hashes oder was man will in User.preferences speichern, für den Programmierer ist es völlig transparent, die komplette “Arbeit” wird einem von RoR abgenommen. Sehr praktisch!

Posted by Eike Bernhardt

Defined tags for this entry: ,

0 Trackbacks

  1. No Trackbacks

0 Comments

Display comments as(Linear | Threaded)
  1. No comments

Add Comment


Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.
Textile-formatting allowed
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA


Submitted comments will be subject to moderation before being displayed.