El Miércoles, 11 de marzo de 2015 04:16:18 Georgiy Avakyan escribió:
> Hi there! I'm using active_scaffold gem -v 3.4.17 with rails 4.1.9.
> I want to add some custom form action. I have
> read
> https://github.com/activescaffold/active_scaffold/wiki/Adding-custom-action
> s#form-actions but still can't add form.
> I'm want to add "form action" that will work with spreadsheet gem
> (https://github.com/zdavatz/spreadsheet). I need to export items in the
> selected interval (from xx - to yy) or all items (in form will be 2 radio
> buttons). I'm trying to add custom xlsx_export action. Can you just paste
> here another example of custom form action with ":type => :collection"?
>
> I can export all records of controller, but can't implement a custom form
> action for it.
It's not very different to member action
class InvoicesController < ApplicationController
active_scaffold do |config|
config.action_links.add :show_export, :type => :collection, :position =>
:top
end
def show_export
respond_to_action(:show_export)
end
def export
process_action_link_action do
if range_selected
from = ...
to = ...
end
do_export(from, to)
end
end
protected
def show_export_respond_to_js
render :partial => 'show_export'
end
def export_respond_to_html
render :partial => 'email'
end
end
# show_export.html.erb
<div class="active-scaffold">
<div class="show_export-view <%= "#{id_from_controller
params[:controller]}-view" %> view">
<%= render :partial => 'show_export' -%>
</div>
</div>
# _show_export.html.erb
disable xhr becuase we want to return file, so ajax must not be used
<%= render :partial => "base_form", :locals => {:form_action => :export,
:body_partial => 'show_export_form',
:xhr => false,
:headline => "Export"} %>
--
You received this message because you are subscribed to the Google Groups
"ActiveScaffold : Ruby on Rails Gem" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/activescaffold.
For more options, visit https://groups.google.com/d/optout.