Confirm multiply data before save - ruby-on-rails

In my app I sometimes need to import some CSV data and I wanna get a view that is shown before save imported data to provide user possibility to check that data is correct. How to achieve it in Rails?

in the first form field, have a hidden field name "confirm" with value 0.
In the rails controller, if the confirm is 0 you just populate with the csv data, show the form again with confirm = 1
if the confirm is 1, then it means the csv was seen by the user, so you can save it.
bonus points-
Instead of showing the csv, make a textfield out of each csv cell- the user will be able to update the fields, not just check if the data is correct.

Related

Update a field of a document in Firestore database

I am an iOS app developer. Right now, I need my app to update his/her scores in the database (Firestore) when a user tabs a button.
I only know that it is possible to add new documents to the database according to the official doc: https://firebase.google.com/docs/firestore/quickstart#swift. But can I simply update one key-value pair within a document at a time?
For example, I have to add 10 points to the user with ID: 1234 if he/she clicks the correct button. So first of all, I need to read the data according to the unique ID, and catch his/her current points. Then put back the points plus 10.
It looks like Firestorage only allows users to upload an entire document once a time.
Swift code snippet is appreciated!
You can update a single or multiple fields in a document with the updateData call.
To atomically increment a numeric value can you can use the FieldValue.increment operation. From that last link comes this example:
washingtonRef.updateData([
"population": FieldValue.increment(Int64(50))
])
This code increments the population field in the document by 50, and leave other fields in the document unmodified.

Print Core Data Results To New Controller and Send To Email

* Edit * So my last question is, how to I get the data shown to be sent in email. I have done much HTML email in my other apps, but am confused as to what I am asking to look for / reference from core data and the proper formatting of code...
Using core date to populate UITable... all good... works as planned... (see pic 1) question... how can I get the result to format and and perhaps display as a UILabel on another controller similar to other results (see pic 2)... and then part two of my question... How can I get that result to print nicely in an email... I have used other code (not from coredata) to print and all works nicely together... I am stumped by the coredata portion...
In the result, you can see the math works out from core data, just don't know how to capture what the user typed in from core data (see pic 3)
Any help greatly appreciated...
EDIT (Clarification)...
I guess I want to show what the user has input into a new view controller and have it displayed in a readable format... (see image)...
Maybe my question is more... how to I PASS the data THAT THE USER CREATED from the Core Data Table Model to a new view controller and display the incoming text as a UILabel? (Can the new view controller be updated automatically? The user may add a new row, delete a row, change the hourly rate on an existing row, change a label etc. etc.. Once that is solved, I'd like to know how to send the results in an email so the end user can print for hard copy documentation... I have this scenario working in other apps, but they do not use core data...

Ruby on rails AngularJS - create multiple models from direct upload

I recently am given a task by upper management to implement a mass upload coupon task. The goal is to allow users to upload an list of coupon codes (excel or csv), and subsequently giving these coupons codes attributes such as start date, expiry, quantity and so on.
I have already implemented a form to input these attributes. The current implementation method I am doing is as follows:
1.I upload a list of coupon codes (eg: 333245454dfee) and I do not write them directly to the database, instead I converted them to string and display on a page for the user to view. (done)
2.from that view page, there is a form with all the attributes. The user can then input these attributes. (done)
3.The user can create all of these coupons codes with the attributes set.
However, I am stuck now because I am unsure of how to mass create multiple codes and attach all the attributes to them. Right now, I can only create one coupon at a time.
So, to summarize, I would like to ask is it possible to
have a field that contains all the codes I have uploaded
I have others fields for different attributes
how to create all the codes I have uploaded as separate models.
I do not need the codes, I would like to hear what approach there are. I am thinking of creating a variable to store these coupons codes first, then loop them. But I have no idea how to do all of that by pressing one single button.
Thanks in advance.
Hmm, how I would approach this problem would be to have the user upload an csv file with 1 column and multiple rows of coupon. Using carrierwave to upload the file and parse the csv file. After parsing it, you should have an array of coupon and you can just input them into the database.
A good reference for your problem would be http://railscasts.com/episodes/396-importing-csv-and-excel

rails: enforce validation check with form with multiple submit buttons

I have a form with multiple submit buttons that trigger different functionality in controller action. One submit button allows user to save csv with format. Another submit button allows user to load csv file with specified format from dropdown. Then a final submit button allows user to save actual formatted records to database. In order to save records, the user must either save csv format first or load a csv format. How can I enforce this validation check? How can I determine one of the other two submit buttons were triggered before the create call?
The problem with using session variable will be if I add a boolean in session after one button submitted, then when they import another csv file, that value still will be in session and give false positive.

Print the table of contents which is constructed using displayTag?

I am Using Struts2 and Display Tag in my Application. And I am Using navigation with partial="true" option in display table.
I have an another requirement that there is print option. If the User clicks on Print icon, the whole content should send all the records irrespective of navigation.i mean all records. Is it possible to achieve this? If only records in the page means.No problem i can do this. How can i send all the records for the print?

Resources