AS and simple_form

36 views
Skip to first unread message

Hernan Astudillo

unread,
Apr 30, 2012, 7:37:23 PM4/30/12
to activescaffold
SimpleForm (and as most of the rails world) name object and form element by a common syntax:

objects:
@class_single_name

forms:
name = class[method]
id = class_method

Which doesn't work with AS, which naming syntax is:

forms:
name =
record_column_       #new records
record_column_id  # existing records

So, is there a trick to make it work with AS, maybe a linking trick (record = params[:"#{class_name}"] ) ?


regards,

ser...@entrecables.com

unread,
May 1, 2012, 2:47:09 PM5/1/12
to actives...@googlegroups.com
On Mon, 30 Apr 2012 19:37:23 -0400, Hernan Astudillo <naa...@gmail.com>
wrote:
In a form override, you get options hash with AS name, IIRC you can
override passing options hash.
Also, you can override do_create and do_update, copying AS code and
changing params[:record], or with this code:

def do_create
params[:record] ||= params[:"#{class_name}"]
super
end

def do_update
params[:record] ||= params[:"#{class_name}"]
super
end

Mike Blyth

unread,
Dec 17, 2012, 8:33:11 AM12/17/12
to actives...@googlegroups.com
When I used do_create (and do_update) to transfer the params[:model] to params[:record], I also had to delete params[:model]. If not, all those parameters are attached to URL paths (not sure which ones, but at least the ones to edit the same object again).
Reply all
Reply to author
Forward
0 new messages