I desperately want to use edge rails to have all the goodies of Rails 1.2, especially the RESTful stuff. The problem is that it’s bleeding edge and I am working on a project that will be public and not for my own desires.
There is a simply_restful plugin available, which is what Rails 1.2 will be modeled after. The problem is that there will be differences between the plugin and the rails source. That means after using one, I have to refactor some code to include conventions like change my delete methods to destroy and some pluralizing stuff as well.
That’s where the simply_restful_backport plugin comes in. The author has made a plugin which implements the RESTful stuff as it will be in Rails 1.2. I am going to try it out this weekend and see how she fits.
So today I had an interesting problem. For whatever the reason, I wanted to have a class automagically be created. It was going to be a helper model, and I didn’t feel like having umteen classes that all did the same thing, just had different names for different tables. My solution: use the power of ruby and metaprogramming.
def create_new_active_record_model(class_name)
klass = Class.new(ActiveRecord::Base) do
belongs_to :old, :class_name => class_name
def some_method_you_want
"something"
end
end
Object.const_set "#{class_name}Target", klass
end
I know that some of this could have been encapsulated in a polymorphic association, but this allows you to do something beyond just keeping everything in one table, like with polymorphic associations.
Read the rest of this entry »
Beast is a nice, light-weight forum written in Rails. From what I can gather, the overall goal is to make something work with only 500 lines of code, and I think that could happen with this. It is open source, and can easily be checked out.
I did check it out and I have to say that I’m impressed. It is using the rails edge and is trying out some of the RESTful stuff all the while adhering to the philosophies of CRUD. I have wanted to look into a good example of a rails project using REST, and this code base is great for that. What’s more is that it’s not very difficult to wrap your head around all of the code of the site, due to the small code base and nice abstraction of the code.
Read the rest of this entry »
A couple of months ago, I was shown the article that DHH wrote after he gave his presentation at RailsConf 2006. I looked at it then and kind of shrugged it off, mainly because I really didn’t know what the presentation was really about.
Tonight I found video of that presentation and I got excited about CRUD. It pointed out that I’ve been making some controllers a little bloated. I have coupled much functionality into one controller; when looking back, I clearly could have separated out some functionality.
Read the rest of this entry »