Is it possible to get back update made on a query without backup? - ruby-on-rails

I'm gonna ask a stupid but desperate question.
Is it possible to get back a query who has been updated same with before without backup of the db.
For example I have the sentence
Hello world
and someone did an update query to
Hello hell
Is there a possibility to go back to before or log where I can find when the original sentence has been created, or maybe (let's think everything is possible) a default backup of my db ?
I'm using RAILS 5, and sqlite3
Thank you

Unfortunately not "by default", Rails doesn't have anything built-in for such situations nor does it log old values when applying updates.
You might want to use https://github.com/paper-trail-gem/paper_trail if you expect this happening often.

Related

How to save a query in Dremio?

Dremio provides a really nice GUI to download and save data generated after your query run.
However, I want to save my query (instead of query result) in dremio so that I can anytime (in future) refer the query that I wrote. Is there a way to achieve this?
Really appreciate the help!
Although this is an old post, I thought it might be helpful to provide a solution. What you are describing can be solved with a key functionality of Dremio. Instead of going through the difficulty of searching for your old query; I would have suggested creating a VDS (Virtual Data Set) by way of the UI. After a successful run of your query you can save it
Dremio Save Dataset Button as a VDS.
After selecting the save button you will be asked where you wish to save it; you can either save it to your default directory or a named Space you have created previously Dremio VDS Save Dialog.
You can query against this new VDS as though it was an actual table. Any changes made to the VDS will be saved in a history - utilizing the breadcrumb trail on the right side of the UI one can navigate to prior versions.
You can now further accelerate this query through creation of a Dremio Reflection...but that goes beyond the scope of your question ;)
In the left upper corner, you should look for Jobs menu:

How to get a total number of hours in Ruby on Rails app and show it on the index page?

I am working on an app where the user can log his working hours after he finished his shift. The app is developed in Ruby on Rails 4.I used the scaffold method, so it generated the necessary methods for create, read, update, delete. The fields are hours_worked:number overtime:boolean and date:datetime, for now, I plan to expand it later with more functionality, with user login and some other stuf. The model is empty, I did used the rake db:migrate method. Now I know that you can use the count method, as is shown on the official site for active record. I don't have the idea how to get the total number of hours worked and show it on the index page. Consider that I just started learning Rails. Any suggestions?
Sounds like this is best used with the Timers gem.
https://github.com/celluloid/timers
In your Sessions#new method, you'd want to initialize a variable to keep track of the current time. And then every so often, you'd use one of the methods in the gem to update the current time. You could then subtract the difference.
This is hard to answer without any info on how you are actually logging the info, or seeing any of your code. However if you are just looking for general suggestions you could just save start and stop timestamps and compare them. Or ask the user to input time worked. There are probably a thousand different ways to do this. Please be more specific on what exactly you need help with.

Hide feature flag when viewed/visited in Ruby

I have a new feature in my Rails project. I need to insert a "New!" flag in its menu, so user will notice that a new feature is available. Once the new feature page is visited, this "flag" must disappear.
How is it possible with Ruby on Rails?
The absolute simplest way is to look for a sawFeatureX cookie and set it when the page is rendered or the user dismisses the notification.
A more robust solution would be to store the info on the user model in the db, but that ends up giving you a lot of one-off boolean fields which may or may not be what you want.
There are MANY variations. You could use something like HelloBar to point out the new content without inlining it into the menu. So. Many. UX. Variations.
But for a one-time thing, a cookie or db-backed solution seems simple and easy.
I hate this problem.
A cookie is easy, but gross and doesn't scale. You really don't want to pay the price of sending this data back and forth on every request until the end of time.
Saving on the user record seems like a sin against database design.
A separate DB table with all these "I saw feature X" seems like such overkill and I hate something that is just going to grow without bound being in my main DB.
You can put it in Redis, memcached, but do you really need to store it in RAM? that's the most expensive place to do this.
I think the ideal solution is something like https://www.prefab.cloud/documentation/once_and_only_once which is a service (i wrote) that stores this little "bob saw X" off in a database I don't need to manage/care. It handles cacheing etc so that it's as fast as having it in Redis/etc but durable and doesn't get expired.

Persisting data in MVC for the duration of a users session

Apologies in advance as I'm sure this topic has no doubt been asked before but I couldn't find any post that answers my specific query.
Bearing in mind that I'm new to MVC this is where I have got to. I've got a project developed under VS 2010 using the MVC 3 framework. I've got a search page which consists of 6 fields and a nested model which itself holds around 3 fields.
I can successfully post all this data back to itself and the data is successfully passed as a model and back agian so the fields keep the data which the user has supplied.
Before I move on to actually using this search criteria on another view a thought hit me. I want to keep this search criteria, and possibly even the search results in memory for the duration of the users session.
The reasoning behind this is simply to save my users time by:
a) negating the need to keep re-inputting their search criteria regardless of how they enter or leave the search page
b) speed up the user experience by presenting the search results more quickly
The later isn't as important as the first requirement.
I've done some google searches and indeed had a look through this site on similar topics. From what I've read using sessions (which I would typically use if developing a PHP site) is a no no. From the reasons I've read as to why you shouldn't use sessions seem valid and I'm happy to go along with it.
But now I'm left in a place where I'm scratching my head wondering to myself what exactly is best practice to achieve this simple goal that could be applied to similar situations later down the line in the project.
I also looked at the OutputCache method and that didn't behave as I expected it to. In a test I set the timeout for 30 seconds. After submitting a search I clicked the link to my search page to see if the fields would auto-populate, they didn't. But then clicking the search button the values in the cache were retrieved. I thought I was making progress but when I tried to submit a new value the old value from the cache came back i.e. I couldn't actually change my search criteria with the cache enforced. So I've discounted this as an avenue to explore.
The last option seems to suggest the use of cookies as the most likely candidate, but rightly or wrongly I feel this isn't the best solution. I would have thought the MVC 3 design pattern would have an easier and recommended method of persisting values. I'm sure there is but I've just not discovered it yet.
I have started to use JQuery and again this has been mentioned but I'm not sure this is right direction to take either.
So in summary my question really comes down to what is considered by the wider community as best practice for persisting data in my situation. Effiency, scalability and resiliancy is paramount as I'll have a large global user base that will end up using this web app.
Thanks in advance!
Pete
I'd just use cookies. They're simple to use, you can persist them for as long as you want or have them expire when the users closes their browser, and it doesn't sound like you are storing anything sensitive in them.

iOS App Store, forcing reinstall

Is there really no way of forcing an app update from the app store to do a complete reinstall? (say your database needs to be updated but you have no real need (or desire) to migrate existing data).
(I am wondering if the only way of getting a new version of an app on the device without the update function, is to complete remove the current app, give the updated (new) app a new namespace/identifyer and upload that from "scratch", and then hope the user will actually notice that the app is now a new app...).
Any suggestions?
Thanks in advance.
The 2nd option seems like a bad idea, users wont have any idea that your app has a new "version" so wont go looking for it, so you would have to send them notifications telling them about it. I cant imagine you'd get a huge percentage of people changing over
If all you need to do is delete the old database and start again you can do that. This question has an answer for an sqlite database. Basically you just need to keep track of which version of the model the user has, and when they upgrade, you delete the old one and set up a new database from scratch

Resources