Displaying 2 results from an estimated 2 matches for "myinstance".
2006 Jul 10
2
Simple question about retrieving id''s
Hi All,
Sorry if this has been covered before, but I couldn''t find a previous
thread on the list that answered my question. Basically I''m creating a
new record in a table like so:
def create
@myInstance = MyModel.new(params[:formVars])
@myInstance.save!
end
My question is: How do I then get the id of the newly created record
within this create method? It seems like it should be pretty
straightforward, but I''m having a brainfreeze about it, and I didn''t see
a method in the...
2006 Sep 26
3
S4 accessors
...rs and replacement functions together. I would be interested
in people comments on the approach I've taken.
The code has a couple of decisions for which I could imagine
alternatives. First, even simple get/set operations on class elements
are wrapped in functions. I suppose I could just use myinstance at slot to
do some of these operations, though that is considered bad style in more
traditional OO contexts.
Second, even though the functions are tied to the class, I've defined
them as free functions rather than methods. I suppose I could create a
generic that would reject most arguments, a...