Is it safe to "search" creating db records in Rails? - ruby-on-rails

I need to build a search form including some fields like "city, price range, key word and date". I saw this video which is recommending to create a "searches" table. Every time any user made a search, it creates a table row in the db, and show the results depending on the submitted fields.
Seems easy to build but is it safe? I mean, if this is used in the practical world, I think we also have to use "I'm not robot" from Google.
https://www.youtube.com/watch?v=QRE7KxIvUb4&t=29s
Any idea is welcome.

Related

Update several Tbl Fields based on Start/End Dates

Good day to everyone! Hope all is well!
I am looking to run an update query or a group of queries that looks at my Date_Start and Date_End to determine if the Units (quantity of the respective record) fall in my defined current quarter 1/2/3/4 from another table (this table is a master table I’m using to provide the dates that I need to consider for defining the quarters).
I’ve been able to create queries that do this and then join them together to basically display the units out by quarter based on their respective start/end dates. The problem I am running into is this process takes a decent amount of time for the queries to populate that will drastically effect other processes down the line.
Thus we get to my desire. I am trying to no avail to create an update query that will update the quarter fields in my table based off of the queries I built to determine if the records start/end date fall in the respective quarter. I figure that running this update when records change will be an ok run time vs when I’m running reports or running an email script for the reports.
I have tried pulling in the table and query, joining them as equal on ID (the query pulls in the table's IDs), and selecting my field “CQ1” from the table, and setting the Update ether the respective field from the table or the query (which is the same as the field in the table).
All I get are the current values of the field in the data sheet view and an error of “Operation must use an updateable query.”
I have even tried placing a zero to see if that would do it with no luck. I have verified that all the fields are the same data type.
What am I doing wrong? Thanks!
Apologies to everyone.....I think my conscious brain was trying to overly complicate the process and while talking to a buddy about my issue distractedly created a new update query that worked. It all tied down to that I forgot to put a criteria on my quarter filed of is not null I believe. Thanks for anyone that has read this and is responding while I’m typing this or for those of you formulating a response.

How to auto populate specific Google Form fields, based on dropdown choice

I use Google Forms regularly at work, and I think they are awesome, especially since I am a total newbie with coding. With a few good plugins for Forms and Sheets, I am able to generate contracts, invoices, and so on very easily, based on document templates.
To keep it short, here is my request:
I have a form, where I input the customer's details, and upon submission, an addon generates a gdoc, based on a template. Al working great so far. My problem is that we are generating many different documents for a single customer, so it becomes a repetitive and very time-consuming task, considering that I have 15-20 different input fields for a customer, plus specific input fields for each different document.
The first input filed in my form is "Customer Name" and I have managed to create a dynamic dropdown list, that takes it's information from a specific column in a Google Sheet.
My request: how could I auto populate specific input fields in my Google Form, so that, based on my dropdown choice, the auto completed information will match the corresponding row present in the Google Sheet.
I have attached 2 images for easier understanding:
You can actually do this with a simple vlookup:
note: I also always wrap my functions with and if statement that checks if there is text in the first field, so try:
pretend that your dynamic customer name is in cell A1:
customer vat formula -
=IF(ISTEXT(A1),VLOOKUP(A1,'Parteneri'!A:C,2,FALSE),)
customer city formula -
=IF(ISTEXT(A1),VLOOKUP(A1,'Parteneri'!A:C,3,FALSE),)

Generating values for dropdown ONLY for 'C' of CRUD

When choosing 'Add' in CRUD, how best to generate a list of choices to pick from a dropdown?
For U/update - just display what's there...
The field contents starts with a letter, followed by five numeric digits:{A-I,K-N,Z}#####
Each letter has a different 'max' value for the numeric part.
So when adding a new record, I'd like to offer a listbox with one of each letter and that letter's highest numeric value + 10.
So, if the max 'A' as A00120, and max 'B' B00030 (etc) the listbox would have A00130 and B00040.. etc
Save the user having to figure out which is 'next' when generating a new record.
? Thanks,
Mark
This time I'll not be able to come up with ready to use solution, but I must say - everything is possible with ATK4. You just have to customize and extend it to fit your needs :)
Speaking about your question above - I guess you have to split it in multiple parts.
First part is about how to show select box on Create and readonly or disabled field on Update. I guess you can make some custom Form field or pin some action to existing Form Field hook. Not sure exactly what's better in this case.
Second one is about data structure. I believe that this field actually should be 2 fields in DB and maybe (only maybe) merged together in ATK model with addExpression() just for user interface needs to display these 2 fields as one field easily in UI. Maybe such concatenated field will be useful also for searching, but definitely not as only one field stored in DB. Imagine how hard it'll be for DB engine to find max value if such field. Store it like type = letter, num = number and then search like SELECT max(num)+10 FROM t WHERE type='A'
Finally Third part is about how to generate this next number. I read your question 3 times and came to conclusion that actually you don't have to show this +10 numeric value in UI at all if it's hardly predefined anyway. Actually that'll not work correctly if this will be multi-user system which I guess it will. Instead just show simple select box with letters {A-I,K-N,Z} and calculate this next value exactly before inserting data in DB. That can be done using models insert hook. This will be much more appropriate solution and will be better for UI and also more stable because calculated in model not incorrectly in UI part.

How to offer parameter for user to select an amt and then show that data

I have done report that shows summary of sales of items by free shipping or not free shipping. They are actually Product lines, that get free shipping or not.
It looks like this.
date Invoice# Free PL NOt free PL etc.
061113 1234 $29
061213 5678 $89
They want to have the flexibility to select ranges of BOTH free PL’s and non-free PL’s (e.g., “free PL’s over $70 and non-free over $30”, or “free PL’’s over $80 and non-free PL’s over $25” etc.)
They want to specify I guess in the param what amount then the CR should display according, so that in out case here only the second line would show.
Is this able to be done just in the param? if so, how would you code this?
this method may be a bit lengthy but will work for you hopefully.
make a table named PL history, now give it three fields, with ID, PL_DATE and PL_RATE, you need to insert new record in to that daily. if you want it to be more finer, add another column as PL_TIME as well. now when inserting the PL_Transaction, make sure that you enter time to that table as well.
Once it is done, make a view and like the transaction table with the respective PL_DATE and PL_TIME if you incorporate time, this will ensure that you pick the right PL specified during the transaction. YOu can do it behind the generate report button, will take no time to execute.
JUst call that view to the report, and get your specific PL using the formulas,
I tried calling a field to the report mannualy, it did come to the report, but it could not be called to the formula editor so , I thought of this solution , may help. thanks

Append Query That Also Selects A Lookup Table Value Based On Text Parsing?

I've posted a demo Access db at http://www.derekbeck.com/Database0.accdb . I'm using Access 2007.
I am importing an excel spreadsheet, which my organization gets weekly, importing it into Access. It gets imported the table [imported Task list]. From there, an append query reformats it and appends it to my [Master Task List] table.
Previously, we have had a form, where we would manually go through the newest imports, and manually select whether our department was the primary POC for a tasking. I want to automate this.
What syntax do I require, such that the append query will parse the text from [imported Task list].[Department], searching for those divisions listed on [OurDepartments] table (those parts of our company for which we are tracking these tasks), and then select the appropriate Lookup field (connected to [OurDepartments] table) in our [Master Task List] table?
I know that's a mouth full... Put another way, I want the append query update the [Master Task List].[OurDepartments], which is a lookup, based on parsing the text of [imported Task list].[Department].
Note the tricky element: we have to parse the text for "BA" as well as "BAD", "BAC", etc. The shorter "BA" might be an interesting issue for this query.
Hoping for a Non-VBA solution.
Thanks for taking a look!
Derek
PS: Would be very helpful if anyone might be able to respond within the work week. Thx!
The answer is here: http://www.utteraccess.com/forum/Append-Query-Selects-L-t1984607.html

Resources