Archive for November, 2011:

Formgen generates views in erb and haml based on these keywords: has_many, belongs_to, accepts_nested_attributes_for, and has_attached_file. It follows best practice and standard patterns so you don't have to. Here is example of its usage:

Doing this

rails generate skizmo:form Foo

Generates this

app/helpers/foo_setup_helper.rb

app/views/foos/new.html.erb

app/views/foos/edit.html.erb

app/views/foos/_form.html.erb

app/views/foos/_bar_fields.html.erb

app/views/foos/_baz_fields.html.erb

That's it:

Ok, so I say that, but there are a few things to note. First, this probably only works with Rails 3, given some of the calls I make for figuring things out. Next, you'll want to yield :head, somewhere in your layout so that the content_for :head that loads the add and remove jQuery will be useful. Finally, you should note that the nested attributes are only processed from the first level, but that will soon change. Anyway, enjoy it and if you have any problems, just let me know.

I've always dreaded doing the view code for nested attributes, setting up the helpers, the javascript, partials etc. Just so tedious, so I thought, I'd try my hand at a form generator. This generator takes a class and then processes all the nested attributes of that class's has_many's and belongs_to's to generate the typical pattern of form partial and field partials you find here.

Yah I did ruby syntax-highlighting ... so not the best for something like that, but eh ... it'll do.

The formgen gem is a 0.1.0 starting point, but has worked for all the things I've needed. If you're feeling brave give it a shot:

This is completely based on the Hello Android tutorial - I didn't really do a whole lot, but the hope is that this will help get some more ruby devs into android development with a simple how-to.

Step 1 - Setup RVM with jruby

Note: RVM is awesome, if you don't use it or don't know about it - read more here.

rvm install jruby
cd /path/to/your/android/pindah/mirah/project/dir/
# using your .rvmrc will trigger `rvm use jruby` when you cd into your project dir.
echo "rvm use jruby" > .rvmrc
# this will make sure your .rvmrc is working, you should then be able
# to use rvm info and see jruby
cd .