2010/5/13 Sergio Cambra .:: entreCables S.L. ::. <[email protected]>:
> On Jueves, 13 de Mayo de 2010 16:30:18 Iñaki Baz Castillo escribió:
>> 2010/5/13 Iñaki Baz Castillo <[email protected]>:
>> > Humm, it's enough to use "params[:id]"  :)
>>
>> Ok, I've got it, except a detail:
>>
>> This member action_link modifies the content of the member so I need
>> that, after executing the action, the row is reloaded via AJAX.
>>
>> With my current code it's not done:
>>
>>
>>     config.action_links.add :empty,
>>
>>                             :label => "Vaciar", :type => :member,
>>                             :inline => true, :position => :replace,
>> :
>> :crud_type => :update
>>
>>   def empty
>>     list.description = nil
>>     list.save
>>     flash[:info] = "Reseteado"
>>     render :update do |page|
>>       page.replace_html active_scaffold_messages_id, :partial => "messages"
>>     end
>>   end
>>
>>
>> Could I get some help on how I must use the 'render' in order to
>> update the row according to the new data?
>
> There is a view to refresh a row, replace your render with this:
>  respond_to do |format|
>    format.html { redirect_to :action => :index}
>    format.js { render :action => 'update_row' }
>  end


> Or you can put only "render :action => 'update_row'" if you only want to
> respond to AJAX requests

This last solution fails as I think it's trying to use @record which
is empty in this case (I'm not handling a member in the controller):


Processing DstBlackListsController#empty [GET]
  Parameters: {"action"=>"empty", "_method"=>"get",
"adapter"=>"_list_inline_adapter", "id"=>"106",
"controller"=>"dst_black_lists"}
  DstBlackList Load (0.3ms)   SELECT * FROM `dst_black_lists` WHERE
(`dst_black_lists`.`id` = 106)
  SQL (0.1ms)   BEGIN
  DstBlackList Update (0.4ms)   UPDATE `dst_black_lists` SET
`description` = NULL WHERE `id` = 106
  SQL (0.1ms)   COMMIT
  DstListEntry Delete all (0.3ms)   DELETE FROM `dst_list_entries`
WHERE (`dst_list_entries`.`dst_list_id` = '106')
Rendering update_row

ActionView::TemplateError (Called id for nil, which would mistakenly
be 4 -- if you really wanted the id of nil, use object_id) on line #1
of vendor/plugins/active_scaffold/frontends/default/views/update_row.js.rjs:
1: page.call 'ActiveScaffold.update_row', element_row_id(:action =>
'list', :id => @record.id), render(:partial => 'list_record', :locals
=> {:record => @record})



I will try the first solution now. Thanks.

-- 
Iñaki Baz Castillo
<[email protected]>

-- 
You received this message because you are subscribed to the Google Groups 
"ActiveScaffold : Ruby on Rails plugin" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/activescaffold?hl=en.

Reply via email to