How would I edit a resource's attribute with name "xxxxx_id" - ruby-on-rails

I have a table with a column name of form xxxxxxx_id. This isn't a key, it's a number that I want to be able to edit myself from the activeadmin console.
However, it seems that whenever a resource had an attribute with id in the name, it is excluded from the activeadmin console. Removing id from the name resolves this issue, but I would still like to know if it's possible to make it an editable text field.

Related

Conditional show/hide fields based on show/hide links

What I try to do is very simple.
I have some fields in a form that are optional to fill. To make the form look cleaner, I'd like to show simple links as Add field and display the optional fields below via js unobstructedly.
If the field is present, it will be saved into the database. The field would also have a delete link. When this delete link is clicked, the field will be removed and also its value from the database when saved.
Seems pretty simple, yet I haven't found a simple approach to this. The whole solution involves many aspects such as passing hidden data to the controller to see if the record was hidden in order to delete its data from the database.
I would prefer a gem already optimized for this purpose but I couldn't found any. What I found is intended for associated records but this is not the case. These are not associations, just optional attributes from the same model.
nested_form_fields gem its also not suitable since it needs a checkbox or radio button to be triggered and not Add field/Remove field links which I believe look cleaner.
Is there such thing as a gem to accomplish this simple thing?
Instead of trying to send hidden data etc. Why don't you just load all the form fields but display:none. When a user clicks the 'show' button you display the field. If the click the hide button, just set the field to null and hide it.
When your form reaches the controller it will save the null value to the db for the hidden fields (same as if you deleted the value).

Rails fields_for from collection with checkboxes & additional attribute

Reference: Rails has_many through form with additional attributes
But it is not solution for me... I want to accept only checked elements, without dependency if other attributes are filled.
E.g.: I want to create my menu. There is each food with checkbox and you are able to edit the price in text field (but you don't have to). I want accept all checked foods & save their new price if filled, or old price if not.

rails autocomplete path on form edit

I have a scenario wherein I create a payer.I use autocomplete-jquery gem for the payer name.
Now I need to edit the same.This is the path I used in both the places
"autocomplete_payer_name".
For new payer autocomplete is working but not for edit.since 18/autocomplete_payer_name no route found.
How do I specify the autocomplete path for edit
Please help.
well I could fix this by modifying the path in my routes to match
'/admin/excluded_payer/(:id)/autocomplete_payer_name',:to => 'admin/excluded_payer#autocomplete_payer_name'
On clicking edit i had a id along with the normal autocomplete call , I just routed it back to the normal one assuming it didn't have the id.
I got this issue while on record edit.

How can I filter the auto populate when editing a form in Rails?

In Rails, when you go to the edit action, it automatically pulls the information from the models and populates the form. If I had a CRUD that saves sensitive information, for example password or ssn, how can I filter the values so that it doesn't just show it in plaintext when editing the form?
I was going to change the value in the controller by setting it to ****, but the potential risk there is people may submit the form and it will update the SSN to ****.
I'm not referring to filtering the params so it doesn't show up in console (config.filter_parameters).
Changing the input field to type="password" should resolve your problem. Just don't set the fields in the controller if they are blank.
If you are using a form builder, change text_field to password_field.

Orbeon Forms - Find current Document_id

I want to have a text box have the current document_id displayed. Is there an XPath expression to get that?
The following XPath returns the current document id, the same that you see on the URL on the edit page you get by clicking on a form instance in the summary page.
xxforms:instance('fr-parameters-instance')/document
Note however that if you use this in a calculated expression, for new forms, the value won't show until a change was done in the form (e.g. users entered a value in a field).

Resources