views:

306

answers:

2

I am developing a "game platform" on ruby on rails. It is not a 2D or 3D intensive game but more like quiz games, imagine typical Facebook quiz or even "how big is your brain" kind of games. The platform will be used by students here to develop easily their own ideas. The point is to create a series of widgets they can just place in the page and make them work on the data and the CSS.

For this I started creating widgets that to be integrated in the page you just do something like

<%= widget_name widget_params %>

Easy enough for them, but for that I need:

  • Methods in the helpers that just render partials
  • Partials with the html elements marked with id
  • functions in the javascript file that look for that id on the page and if found do their job (as most widgets will somehow use JS)
  • Data support in the model.

For instance, my timer is a javascript function + a partial with game.timeout being game a model with a column timeout for each game. and all that is wrapped in the helper so the user just use <%= timer @game %>

Note that the widgets need to alter the page or at least send some kind of signal to the controller of the page to tell him about global changes. For instance, the timer widget will not only terminate itself but should tell the game controller the game has been terminated also (that's why they are partials in the same page instead of iframes).

The interface for the students to use (just one liners ) is easy and I like that but the fact that each widget need touching so many places, avoid me to easily deploy new widgets to the framework and in general looks like an horrible design.

Also I have just (1 hour ago) discovered Extjs and as I will develop GPL, I am considering it.

Any way to have extjs or any other hand made or provided widget more isolated but still be able to alter a more global context?

+1  A: 

In a production application, Rails Components are frowned upon, but if your application is for teaching purposes and the students will not be modifying the components, then I don't see why not to use them.

Redbeard
A: 

Did you already discover Apotomo? That's event-driven widgets for Rails with optional statefulness - very GUI-like.

Nick