?> c => Call.1
SyntaxError: compile error
(irb):3: syntax error, unexpected tASSOC, expecting $end
c => Call.1
^
from (irb):3
?> c = Call.1
SyntaxError: compile error
(irb):5: no . floating literal anymore; put 0 before dot
c = Call.1
^
(irb):5: syntax error, unexpected tINTEGER
from (irb):5
On Thu, 07 Feb 2008 21:16:49 +0000, Frederick C. wrote:
Haven’t you already had to do this dozens of times in your rails app?
It’s just f = Foo.find 1
I’m trying to use the console a bit more. Does that specify that the id
field==1, or does that just do a general search through all fields? I’d
like to specify the id field/attribute.
The console it just an irb session that has been initialized with your
rails application. Anything that you can do with a model, you can do
in the console. Not so much with controllers though as they expect to
have request object. (In fact, this is IMHO one of the strongest
examples of why the “fat model/skinny controller” style is the way to
go.)
Are you asking about how to indicate that your primary key is not
called ‘id’? If so, look at the docs for ‘set_primary_key’.
If you want to match some other column, you have the dynamic finders:
Foo.find_by_id(1)
or explicitly using conditions:
Foo.find(:first, :conditions => [‘id = ?’, 1])
Foo.find(:first, :conditions => { :id => 1 })