Forums | Admin

Discussion Forums: help

Start New Thread Start New Thread

 

By: Bill Cunningham
RE: Syntax Errors in User.rb [ reply ]  
2003-12-12 23:28
Wow, I never thought an insignificant little space could be so significant.

That cured it.

Thanks much, Francis.

By: Francis Hwang
RE: Syntax Errors in User.rb [ reply ]  
2003-12-12 13:06
I think the problem is that I wrote those examples in Ruby 1.6.8, and now you (like most everybody else) are using 1.8. The syntax is slightly different. This line won't compile in 1.8:

fields << TextField.new (self, 'firstName')

but this line will

fields << TextField.new(self, 'firstName')

( no space between "TextField.new" and "(" )

I still have to double-check all the tutorial examples to make sure they work with 1.8. Please ask if you have more problems.

By: Bill Cunningham
RE: Syntax Errors in User.rb [ reply ]  
2003-12-08 22:57
Once again, the ^ goes under the first char in "self".

By: Bill Cunningham
RE: Syntax Errors in User.rb [ reply ]  
2003-12-08 22:56
I was hoping you wouldn't say that...

Here is what I get when I run the main script,
which includes the User.rb script (where the actcual error occurs):

bash-2.05$ ./test.rb
./test.rb:5:in `require': ./domain/User.rb:8: syntax error (SyntaxError)
fields << TextField.new (self, 'firstName')
^
./domain/User.rb:8: syntax error
./domain/User.rb:9: syntax error
fields << TextField.new (self, 'lastName')
^
./domain/User.rb:9: syntax error
./domain/User.rb:10: syntax error
fields << TextField.new (self, 'email')
^
./domain/User.rb:10: syntax error
./domain/User.rb:11: syntax error
fields << TextField.new (self, 'password')
^
./domain/User.rb:11: syntax error
./domain/User.rb:12: syntax error
fields << DateField.new (self, 'birthday')
^
./domain/User.rb:12: syntax error from ./test.rb:5

By: Francis Hwang
RE: Syntax Errors in User.rb [ reply ]  
2003-12-07 17:31
Hi Bill,

All looks good from here. Can you post the error traceback you get?

By: Bill Cunningham
RE: Syntax Errors in User.rb [ reply ]  
2003-12-07 17:13
Thanks for the quick response! Here is what's happening.

In the Lafcadio tutorial (http://lafcadio.rubyforge.org/tutorial.html),
everything works until step 4.1. I create a script called test.rb by cutting and pasting from the tutorial:

#############################################################
#!/opt/bin/ruby
require 'config'
require 'lafcadio/objectStore/ObjectStore'
require 'domain/User'
tenYearsAgo = Date.today - (365 * 10)
john = User.new ({ 'firstName' => 'John',
'lastName' => 'Doe',
'email' => 'john.doe@email.com',
'password' => 'my_password',
'birthday' => tenYearsAgo })
objectStore = ObjectStore.getObjectStore
objectStore.commit john
#############################################################

The script gets an error on the third require statement. If I go into 'domain/User.rb' (see below), the problem seems to be in loading the fields array. The syntax error is with each of the words, "self".

The constructor for TextField is:
def initialize(objectType, name, englishName = nil)
super objectType, name, englishName
@large = false
end

So I'm calling this with "self" as the first parameter, the constructor is looking for an objectType, and the syntax error occurs at this point. objectType ends up being just an instance variable in ObjectField.

I have tried removing self, quoting it, etc., but the error persists. Thanks for any/all light anyone can shed. I know this is probably easy, but this is my second week of Ruby. Please
humor this novice!

#############################################################
#User.rb...
require 'lafcadio/domain/DomainObject'
require 'lafcadio/objectField/TextField'
require 'lafcadio/objectField/DateField'

class User < DomainObject
def User.getClassFields
fields = []
fields << TextField.new (self, 'firstName')
fields << TextField.new (self, 'lastName')
fields << TextField.new (self, 'email')
fields << TextField.new (self, 'password')
fields << DateField.new (self, 'birthday')
end
end
#############################################################

By: Francis Hwang
RE: Syntax Errors in User.rb [ reply ]  
2003-12-07 12:42
Could you post the entire method so I could get a better look?

By: Bill Cunningham
RE: Syntax Errors in User.rb [ reply ]  
2003-12-07 02:18
Concerning my last, ^ should be under first char in self, not fields.

Thx.

By: Bill Cunningham
Syntax Errors in User.rb [ reply ]  
2003-12-07 02:16
Hi,

I am new to Ruby; please excuse what may be a stupid question.

I am trying to get the Lafcadio tutorial working. Have ruby 1.8.0, lafcadio 0.3.3.

The file /domain/User.rb gets the following error:

User.rb:8: syntax error
fields << TextField.new (self, 'firstName')
^
This seems to be due to TextField's parent, ObjectField, not liking "self" as an objectType.
What is the fix for this? I have tried quoting self, etc., to no avail.

Thanks in advance for any/all help.

Bill Cunningham