YAeZRW
Yet Another eZabel Re-Write.
So, my current host may be shutting down services either Jun 1, or Jul 1. I need to start looking for another host AGAIN. >:(
The biggest problem I have with hosting eZabel is that it's written in JSP/Java. Java hosting is not exactly popular, so it's hard to find any decent hosts that offer a good package for a low price.
I can either find a good new home for the Java code (i'm working on this). Or, I can rewrite the site in a language that's more easily hosted.
PHP is an obvious choice, but I'm not really interested in that language. Ruby on Rails is what I'm interested in. And Dreamhost supports it.
I've actually already started a rewrite of the site in RoR, but, of course, it's a long way off.
Any thoughts on this? RoR a good idea? It seems to be gaining popularity, so that is a good thing for hosting. The speed of development is also VERY fast with RoR.
Would anyone be interested in learning RoR and contributing? I could purchase a Dreamhost account, and set up a Subversion repository to get some group development going.
Since time is so short, speed is important. The more hands on deck, the better. Maybe. Software development can be tricky like that. haha
AI Summary
71 Comments
Also got some basic role authentication working using acl_system.
http://brainspl.at/articles/2006/02/20/new-plugin-acl_system
It's pretty nice. It doesn't offer model based authentication tho.
For instance, using it I can make sure that only Administrators or Moderators are allowed to run Delete or Edit on something, but I can't allow the owner of a specific record to run Edit or Delete on it. Or I can't restrict access to the moderator forum to only moderators.
I could easily do all the restrictions using just normal logic checks in each action in the controllers, but it would be nicer if I could implement some of the logic in the models.
Found model_security: http://perens.com/FreeSoftware/ModelSecurity/Tutorial.html
It's a generator that creates an authentication system including security at the model level. Very nice looking. I've installed it and am starting to modify the generated files to match my needs.
So, I started down the road of implementing model_security, and I eventually backed off.
It seemed to reaaally slow down page times. And it was problematic with forms in partials. It's got some great ideas, but, maybe it's a little more than I need.
So, I removed model_security, and instead went to a simpler design. I'm just putting readable_by?(user) and editable_by?(user) methods into my models that define the rules. Then I check the appropriate method in my controllers. @model.readable_by?(current_user)
Hey, it works! haha
I also worked on Polls a bit. I've got the tables cleaned up, the data migrated, and the polymorphic associations in my models. so, the Topic class now has_many :polls, :as => :pollable, and the Poll class belongs_to :pollable, :polymorphic => true
I've gotten the polls working in View mode, and also attached to Topics. I have to get voting working, as well as clean up the scaffolding for creating/editing new polls.
Less than two weeks till I have to move the site! :( And I still haven't gotten a new host!
you've probably heard of it, but textdrive hosts rails sites:
http://www.textdrive.com/hosting
$12/month for shared hosting.
yeah, everybody's site on there seems real slow tho. dreamhost does hosting for $7.95/mo and they support RoR. i've only heard slightly better things about them. i also have a coupon that gives you a free year of hosting.
but i found another guy that might do it for me for what i'm paying now. hopefully i'll find out this week.
Implemented messaging! Only took me about an hour or so to get the basics done.
Very easy!
So, I have News, Threads, and Journals working in the new codebase. I also have commenting working in a minimal fashion.
I'm missing Access Control, FAQs, Events, Pictures, Private Messages, New tags for comments, and Polls.
I'm thinking that I'll need to get at least Access Control and Messages in place to make the move. Should be doable. Done!
doable is a weird word... like.. i think you should say DOUGHable... i dunno... just wierd.
doobieable
doogiehouserable.
I've used the Login Generator:
http://wiki.rubyonrails.com/rails/pages/HowToQuicklyDoAuthenticationWithLoginGenerator
Here's a tutorial that mentions the Login Generator:
http://www.aidanf.net/rails_user_authentication_tutorial
Also found this (but I haven't looked into it):
http://penso.info/rails/auth_generator
Oh, I forgot to mention that. I'm using acts_as_authenticated right now, so I've got logins working. It was suggested to me by the IRC guys.
http://technoweenie.stikipad.com/plugins/show/Acts+as+Authenticated
The access control I'm talking about is more like admin functions, and making sure users can't see each other's private data. I started messing around with acl_system http://brainspl.at/articles/2006/02/20/new-plugin-acl_system
I may use ActiveRBAC or something else in the end, though.
ugggg
Hello,Rapidstores webhosting and domain registeration services will be shutting down permanently on July 1st. This is being done due to a lack of profits as well as a general lack of time to supply the kind of support many of you have come to expect.
At this point you have 3 weeks before the service shuts down. That should be plenty of time for finding other hosts. All subscriptions will be cancelled soon.
I am sorry for any inconvenience this may cause. The Support and Sales emails will not be answered from this point onwards, so if any of you wish to speak with me the besy way would be to contact me via email.
Thankyou for your loyal support over the past 1.5 years.
What does this mean to us troglodytes? You got something lined up? Is it contingent upon the 'Red Train' thing your working on? ;-)
Your like the guy who controls the crack... and your landlord is kicking you to the curb.
hahaha, yeah, i'm totally enabling all of you addicts, aren't I.
well, I have something potentially lined up. but, yes, it requires moving to an entirely new architecture, which is the bit of voodoo i've been cooking up over the past couple of weeks, in my spare time.
the biggest hassle is moving all of my other sites over to a new host, and keeping all the email intact and such. uggh
maybe i will make a donation for all your hard work. maybe.
new eZabel feature! Mandatory Donations!
and Top Users get to skim 30% off the top for their video game funds...
If one were to, hypothetically, put a dollar amount on the transition, what number would one come up with? Just for kicks?
I have comment threading working (display only).
The model for storing comments in the current ezabel schema is an Adjacency List. I have a parent_id that references the id of it's parent in the same table.
(side note: the current java code actually stores the comment_id in the parent_id column. So if you reply to the first post in a thread (#1), which is comment.id = 327911, a 1 will be put into the parent_id, instead of 327911. yay for no referential integrity! :( so i ran a migration that fixes all the data. since MySQL doesn't allow you to issue an update that has a subquery referencing the same table, i had to process it a row at a time. took like 3 hours locally. uggg. can't wait to run it again on the prod db)
So, anyway, I'm using Rails' built-in acts_as_tree, which supports the Adjacency List model. It knows about parent_id and what it means. The bad part is that it uses multiple queries to retrieve all the nested comments. So to retrieve a thread with 400 comments takes like 25 seconds. UGGGG
The other built-in option in Rails is acts_as_nested_set. This is much more efficient for querying, but it will be a HUGE pain to migrate the data to the schema required for that.
I could implement my own sort of acts_as_tree loader that loads up all the comments for a thread in one query and then threads them in memory (similar to how the current Java code works). But I'm really not familiar enough with Ruby or Rails yet to even start to figure it out.
Anyway, I feel like I'm making some progress. Once the basic functionality of the commenting system is in place (alllmost there, just need to get replies working), it really should be a breeze to finish the rest up.
Anybody know of a place I can set up an SVN repository?
not sure how easy it is to get an project up there, but you could try rubyforge.net
rubyforge is only open-source, but you can still control the commiters list, I believe.
NICE
http://wiki.rubyonrails.org/rails/pages/UnderstandingPolymorphicAssociations
Looks like I should be able to do this:
class Comment < ActiveRecord::Base
belongs_to :commentable, :polymorphic => true
end
class Journal < ActiveRecord::Base
has_many :comments, :as => :commentable
end
Just have to rename generic_id and thread_type in the comments table to commentable_id and commentable_type, and do a quick update on the data to match the model names.
We'll see if it works!
Works great! I'm running a migration that puts the correct data into the 2 new columns. It's going to take hours... gotta find a faster way to do it. haha
Ok, that's better. 148 seconds to add the new columns, update them, and add the indexes. 270,000 rows in the comments table. Sheesh!
And it looks like I'll be able to take advantage of Single Table Inheritance for the three similar models (News, Journals, ForumThreads), and at the same time take advantage of the Polymorphic Association with :as => :commentable for all the various models that accept comments.
NICE
Yep, I found a bug. STI and Polymorphic Associations don't play together nicely all the time. nzkoz (rails core member) says it's a real live defect.
Details here http://rafb.net/paste/results/cVQNiO28.html
Ok, not a bug. Whew. This is good news.
Ian, have you ever been to another country and got to a meeting and even thou it is in a language you don't understand... you can still pick out the brother that is really into their talk, exuberant, excited about the information. I have no clue what your talking about here, but I AM HAPPY 4U!! :-)
haha, thanks for the encouragement :)
sweet. I think this started in rails 1.1 which I need to get up to speed on...
Here's a design problem I'm running into.
I have a bunch of different objects that all need to accept comments.
Topics (News, Journals, ForumThreads) Single Table Inheritance
Pictures
Events
Faqs
Polls
It's obvious that News, Journals and ForumThreads are all pretty much the same thing, and fit nicely into the Topics table. The other objects really don't fit in. They all have SOME common attributes, though, like a title and body (except for Polls).
Yet, all of these objects need to be commentable. I'm having trouble figuring out a clean way to model this.
The comments table references the various types with two identifiers: thread_type, and generic_id. thread_type is basically an enum(News,Journal,ForumThread,Picture,Event,Faq,Poll). And generic_id is the id of the referenced table.
I can't decide whether I should combine the remaining commentable tables into the Topics table and manage everything at the Topic level, or stick with the current schema and try to make it work... i dunno
Why do you need to reference both thread_type and generic_id? Couldn't you make sure that generic_id is unique across the various tables? If not, then you could add another table (maybe called "COMMENTABLES"?) that maps the local generic_id to a globally unique id which you could then reference from the comments table. If you have properties that are common to things which can be commented on, then you could add them to that table as well.
Yeah.. that's why; the legacy schema has a separate table and sequence for every type of topic. Kind of unwieldy.
I've been thinking about it a bit. I may go down the road of merging all the commentable types into a single table. It'll just be a bulky table. Events, which has LOTS of unique fields, I may make a child table for that holds all the unique stuff. Not sure if that's the best way to do it tho.
The bottom line here is you really want to deal with a commenting functionality the same way for every entity, right?
Personally, when it gets down to objects having similar fields sometimes it doesn't make sense to try to pool them into a common category because it could be a maintenance nightmare trying to add anything in the future.
Yeah, I want to have common functionality.
Last night I worked on the problem a bit more using the existing schema (it's a big job to change the schema and update all the foreign keys in the comments table).
I came up with a RESTful URL scheme for posting comments:
/comments/new/:type/:id
For example, if you POST a comment to /comments/new/journal/256, it will take "journal" as the type, and use it like so:
@obj = params [:type].camelize.constantize.new.find(params [:id])
This retrieves the correct object to add the comment to, so then I just call
@obj.comments.build(params [:comment])
This is a partial solution to the problem. Gives me a central place to add comments to topics.
I'm still not happy with it overall, though. I mean, it works, but it's really not the cleanest solution.
thats a pretty neat way of doing it. very DRY, but maybe a bit hack-ish. but if it keeps the code tight, it could be a good thing.
Shoot Donovan a message - he's recoding our page in JSP and found a host for like $9/month. I can't remember the name of the company, though.
i read "message" as "massage" ... i thought to myself, i guess di thinks that would be enough motivation for him to help out
Hahhahahhaaaaaaaaaaaaaaaaaa!!!!!! EWWWWWW!!!!!
rails is ridiculously easy for this kind of application, sorry I'll try to read mor of this and post some pointers, but wiki.rubyonrails.org is amazing.
i've started the work. i've been fixing up me schema a lot, and i've got some of the basic functions of the site up and running locally.
in a few days, i'll be ready to check the code into SVN or CVS and get some real development started.
yeah. that's the most important part. make sure your relationships are good. Also you should look into "Single Table Inheritance"
for example
class Topic
end
class ForumThread < Topic
end
class Journal < Topic
end
you'd have one table like:
CREATE TABLE `topics` (
`id` int(11) NOT NULL auto_increment,
`title` varchar(255) default NULL,
`author_name` varchar(255) default NULL,
`written_on` datetime default NULL,
`content` text,
`type` varchar(50) default NULL,
PRIMARY KEY (`id`)
);
j = Journal.create(:title=> 'my journal', :author => 'me', :written_on => Date.new, :content => 'some content here')
would create a record in the 'topics' table with the 'type' field set to 'Journal'
Basically, you get and save Journal objects as if they were in their own table. And you can also get all Topics (be they Journals, ForumThreads or whatever) by performing operations on the supertype "Topic"
Topic.find(:conditions => ...)
ActiveRecord is a really really cool framework.
(I stole some of this from http://wiki.rubyonrails.com/rails/pages/Inheritance, which just happened to explain STI using a Topic and a Reply class.)
i definitely gotta do it that way!
i do it like that in the current Java code now, to a certain degree.
but if i clean up the schema a bit more, this could really shine.
yeah. I haven't looked at ezabel schema in a while, but I remember you doing something like this. But the difference in Rails is, its part of the ActiveRecord framework. good support for this kind of thing.
yeah that's really sexy. it figures out the type by the class name?
part of the problem is that I have different tables for everything
news, journals, threads, faqs, events.. all different tables.
i'm pretty sure i could merge news, journals, and threads. but some of the tables have columns specific to the type. i would have to either decide whether or not i really need the extra attributes, or just merge them all in. or have a child table by type or something.
yeah, that is a slight drawback to STI. it's illustrated here:
http://www.martinfowler.com/eaaCatalog/singleTableInheritance.html
all properties of all classes in the inheritance tree are present in the table as fields.
but its not really a problem, as the unused fields are just left unpopulated.
yeah that works. sti helps with searching too.
So, i wrote a migration to create a topics table to merge news, forum_threads, and journals into one table. I combined all the columns. There's only a few that aren't shared, so that's not bad.
Got it working, seems pretty nice.
The only thing I'm wondering now is... do I need separate controllers for each of the models now? So much of the logic is the same, and I want to keep it DRY. Any ideas on sharing some of the logic?
Any chance any of us mortals could look at the schema? :) I'd really like to see how it's organized.
def. i'll have something to show you in a few days (after i'm done cleaning everything up).
the bad part is that i'm using MyISAM tables in MySQL instead of InnoDB. So, there's no foreign keys and no transactions right now.. works good enough though :)
here's the schema after a hefty clean-up. there's still a lot of cleanups to do, but it's much better than it was. i'll fix the remaining problems as i go.
/files/out.txt
you should be able to turn that into some Model classes pretty easily. at least with some of the relationships
Yeah. I've only made some of the models so far. Like, I've got the homepage working with news stories, and forums and threads all working. Comments come up in a basic layout (no threading yet). Login is (was) working. And Journals are working.
I haven't gone through and done much more than what the scaffolding provides for most parts, yet. Have to make the forms pretty, and fill in all the needed stuff on saves that shouldn't be entered by form.
I think my next step is to set up Migrations to make the db part easier.
loving Rails Migrations! ( http://media.rubyonrails.org/video/migrations.mov )
i've been evolving my schema a bit using the feature, and it really makes things nice.
yeah, that's one thing I hadn't looked into, but I probably should have on my rails project...
I have a bunch of stuff working in Rails already!
We could do this site in .NET in like a couple hours :)
really? a couple hours? i challenge you to a duel!
"a couple" as in "a couple million"
I wouldn't mind helping out. Always useful to learn something new.
yeah? i know you do java stuff. have you done any web programming before?
Not too much. Lately I've been doing more back-end stuff. But it is something I've wanted to learn more about.
if you've got 15 minutes, watch this presentation of RoR. let me know what you think
http://media.rubyonrails.org/video/rails_take2_with_sound.mov
That looks pretty cool, and quick for getting a prototype up and running, but I wonder how much work it would be to actually customize everything. Also, how hard is it to port an existing application with its own datamodel, page flow, etc... to their framework?
Seems like it could be an interesting project.
The scaffolding is nice for generating the basic CRUD pages, but it's really just a starting point. It's a little bit of work to really get your pages working how you want, but it's really pretty trivial stuff.
I've been writing some DDL scripts to alter the ezabel schema to fit in with the RoR convention as I go. In the end, I think it makes things cleaner, and it really makes sense.
And as far as page flow is concerned, it's so easy because the framework is MVC is so baked in, you just follow the model. Makes it very easy.
Plus, the language Ruby itself is FUN to write in!
lol. I like how you capitalized "fun".
I'll take a look at it. I really know very very little about web programming. I was pretty good with learning programming languages, I'm just really not motivated to actually learn them, usually. If I get a chance, I'll check it out. How would you split up the work so that no one is working on the same stuff?
by