Posts tagged ‘Rubyonrails’
qs = Question.find_by_sql "select X.* from ots_schema.questions," + "XMLTABLE (\'$d/question\' passing document as \"d\" " + "COLUMNS question_text VARCHAR(200)" + "PATH \'question_text\') as X"
qs.first.question_text.lstrip => "Which of the following is the correct syntax to set the DB2COMM variable to TCPIP?\n "
If DB2 was had a good DB2 driver and a ActivePureXML (or something adapter) it would so f*ckin rock. Just look at the sample. And the dynamic nature of ruby would enable the flexibility of xml documents.
Please IBM please. DB2 for mac and decent support on Ruby. Don’t make me write things like this no more:
# Once again fixing IBM_DB bugs the ugly way # with_scope anyone? add_index :'ots_schema.users', :login
t.column :document, :xml
In this six months Steve could have contributed to the rails core and improved the framework to a great extent. If he found security issues like the article refers than he should have fixed them in rails. I cannot even begin to understand why he didn’t by the way. Or at least reported them.
My conclusion of seeing that google allowed a employee to waste 6 months of work because they don’t want to increase the number of languages that must be supported by their infrastructure is that Google is Dumb.
The question is:
So will this bring something new to the web?
Yes! But it’s not that this wheel is great and the other was flat. It can bring something but just because Google has the power to do that, in any language they decide to use. They have the man power to go beyond what rails offer.
But does this make the decision less dumb?
No. They could do it in rails and improve a great open source product.
Or is it that hard for engineers at google to learn a new language??
Finally we will be able to refactor our ugly code when we have this situation (changeset 9067):
class User < ActiveRecord::Base has_many :channels end
class Channel < ActiveRecord::Base belongs_to :network belongs_to :user end
class Group < ActiveRecord::Base has_many :channels has_one :network, :through => :channels, :conditions => ['channels.alive? = ?', true] end
Another good news is that the RubyForge place for the OTS project was finally approved. So guess I will be doing some work on it this afternoon.
If your working with DB2 on Rails you probably need to check if the xml document is – at least – well formed.
I found a neat plugin called validates-xml that uses REXML to see if documents are well formed.
To install it simply
svn co http://validates-xml.googlecode.com/svn/trunk/ validates-xml-read-only
And copy that folder to vendor/plugins.
You can easily integrate schema validation with a validates_xml_with_schema method. But you should use REXML as it cames with the standard ruby bundle since version 1.8.
To use it simply restart your server and
Well it’s been a heck of a week, loving somethings on rails and hating others :P
Anyway I had a problem with working with different models on a form. If you are having the same kind of issues I’ll give you some pointers:
- Railscasts (ep.73, 74, 75)
- The problem I had and the solution I found (newbie code inside :P)
- Implementings has_many relationships on RailsForum
- Rails: Presenter Pattern (thanks to André Medeiros)
- Chunky Bacon!
My notes file is so big I think I’ll never solve all those issues. *g* Anyway another pointer I can give you is to check out haml. I didn’t used it but it sure is simpler than html.
So your doing a find on your model and you want a random instance. I didn’t find a method to do this so I decided to make my own.
In this case I wanted a random quote. So after generating the model all I had to do was:
def self.random Quote.find_by_id rand(Quote.count) + 1 end
And now you can simply call your random quotes in any controller action you desire. Just
@rquote = Quote.random
If this is the lamest ruby ever please feel free to give me some feedback :) I will be delighted to learn a different way!
I found Ruby in a talk with one of my friends. We were talking about how a problem that can be solved in Haskell in one line of code, could take hundreds to do so in Java or C#. It was obvious that, for some specific problems, Haskell was simpler and adequate.
Want a sample? Code permutation with n levels in C.
perms xs 0 = []
perms xs n = [ p : ps | p <- xs, ps <- perms xs (n - 1)]
And like this he introduced me to Ruby on Rails. I was very thrilled to see a language that is dynamic, object oriented and adequate for web developing. I immediately thought about learning it, I just love learning new languages.
Today I checking my feeds and found a post about seven reasons to switch back to PHP (from Ruby).
It seems Ruby is like Haskell: the code looks greats and promises a lot, but it still doesn’t get where imperative languages do. (I’m still going to learn it, I just can’t resist it)
If you know such programming language leave it as a comment.