Still a Ruby Newbie

Posted by closetmaster Sun, 12 Feb 2006 04:27:00 GMT

I am not sure why, but the following code generated errors for me: @pieces = Piece.find(:all, :conditions =>”user = ’#{@session[:user].id}’”)

I had to save the @session[:user].id, like this… tmp = @session[:user].id @pieces = Piece.find(:all, :conditions =>”user = ’#{tmp}’”)

This probabaly has something to do with ruby saving @session[:user].id as an string instead of an integer. I am having a similar problem right now in another portion of my code, I think. In order to show an image, I had to save the instance variable in the controller and then access it in the view rhtml file using piece3.picture. Update: In the Progamming Ruby: The Pragmatic Programmer’s Guide, the author notes that,

When Ruby constructs this string object, it looks at the current value of name and substitutes it into the string. Arbitrarily complex expressions are allowed in the #{...} construct. As a shortcut, you don’t need to supply the braces when the expression is simply a global, instance, or class variable.

I am guessing that @session[:user].id returns a value, so that when you try to take the value of the value @session[:user].id, you get some garbage.

SeaSide

Posted by closetmaster Thu, 19 Jan 2006 23:05:00 GMT

Evidently, there is another ruby web framework: Borges. Hopefully, it will be just as easy to use as rails. I haven’t downloaded this to try. It is difficult to justify trying something in place of rails when it is so easy to use. Borges is based on SeaSide. After listening to the Ruby on Rails podcast, I was under the impression that SeaSide was a framework for ruby, too, but from everything that I have read SeaSide is for smalltalk and Borges, which is very much like SeaSide, is for ruby.

Older posts: 1 2 3


designed by jowensbysandifer