Hi Jim
I'm not sure if I get what you ask for.
URL to edit form it's /controller/id/edit, it will open edit form in page. If
you ask for an url listing one row and open edit form, there is no one, but
there is url to listing one row (/controller/id/list), you can override
list.html.erb and add JS to open edit link, e.g.:
<%= render :super %>
<% if params[:id] %>
<script type="text/javascript">
$(document).ready(function() {
$('a.edit.as_action').click();
});
</script>
To embed activescaffold in another page you can use render active_scaffold:
controller_name, it will use JS to load controller index, you may load a
different action, although it will render layout, because activescaffold has
code to disable layout in index action only when loading embedded.
You can add to your view:
<%= render active_scaffold: controller_name, params: {action: 'edit', id: id}
%>
And add this method to your controller:
def edit_respond_to_html
if loading_embedded?
render :action => 'update', :layout => false
else
super
end
end
El miércoles, 25 de julio de 2018 6:35:12 (CEST) Jim Crate escribió:
> Is there a way to link directly to the edit form for a record? I know I can
> pass a param and use conditions_for_collection to filter the list to the
> record I want, but it would be nice if I could open the edit form
> automatically as well. I can probably come up with some javascript to count
> the table rows and trigger an action if there’s only 1, but maybe there’s a
> better way to do this.
>
> If the edit form could be displayed by itself, especially embedded in a page
> with other content, that could be useful too. I could also use javascript
> to run the edit action like the listing does, but I’m not sure how much of
> the styling is linked to the table or higher-level containers
>
> Any pointers would be appreciated.
>
> Jim Crate
--
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 https://groups.google.com/group/activescaffold.
For more options, visit https://groups.google.com/d/optout.