How to make one page real-time in Rails app? [closed] - ruby-on-rails

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have an app that is already fully built, the only thing I'd like to add is real-time rendering of one of my pages.
Suppose it is a page with all the pizzas. When pizza is added to the database, I'd like page to show it without refreshing.
I know you can do it with websockets, but is there any easier way? Could, eg, AngularJS help here (as I understand it refreshes the page contents as soon as model is changed)?

Well you could make a small service in Angular that asks the server like every 15 secons or so, to see if there are new pizzas added to the database. (Say the last time you took the pizzas from the server you had 15 of them returned. Now you send that number 15 back with the check request and compare it with the database)
If so, it will call the query method in the pizza Angular service to fetch the new pizzas.
If this is a small table with often changing info then I would also suggest to migrate this model into Redis instead. Asking info repeteadly from Redis is a lot cheaper than it is to ask like this from a database.

Related

How to model common information for Rails application [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I'm a bit new in rails development I'm modeling a website with few resources and so far so good. But here is my question:
I would like to allow the admin users to manage information show in most of the pages: Application name, telephone number, address, default email and this kind of things.
My current idea is make a model Property with name and value, but somehow I'm not convinced about this approach because I'll need to access the database to get this values for every request.
Thanks everyone for your time! :D
This seems like an OK approach. If you implement caching, it no longer will hit the db with every request, and honestly it probably isn't really that big of a deal even without the caching. Build it the way you need, and optimize afterward, if necessary.
With all this being said, it may be worth considering how much things like the phone number are going to change, and balance the cost of developing a dynamic solution against the time it would take to change once, 3 years from now (if the number ever does change), in a partial.

Should I also store fetched data local in my app? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I'm making an iOS app where I fetch data from a MySql database via a web api (in JSON format). When I load a specific screen the first time should I always save the fetched data local or it is okay that I fetched the data again when the app opens again from being closed/killed? My app has a login in module so right now I only store the current users information local. I also fetch images but those I cache.
You're asking whether to cache the information you download from an API or toss it and grab new every time? This is a very opinionated answer, but to me, it depends on how often the information you're fetching updates or changes itself. Do your users expect to see totally different information every time the app loads? If yes, maybe you don't need to bother caching. The Facebook app, after being killed, opens to a pulsating loading newsfeed. The twitter app, on the other hand, shows you the most recent tweets it loaded then shows an inline notification that more tweets have loaded and you should scroll up to read them. There's no right or wrong answer, it's really up to you.

Solution for voting without attachment to a model? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
My application is one page contract. I would like users to be able to sign the contract by clicking on a button. The contract is not a resource; it's plain HTML.
Every solution I have found so far relies on having a model that acts as votable. How can I implement a simple button that users may only click once, and display the number of users who have clicked it?
It's not possible to do this with static pages, at least not in a way that is clean and secure.
Think about it this way: every user is looking at a copy of the contract, which is being displayed to them on their browser (the client). If you want users to be able to cast votes that persist and be aware of votes cast by other users, then you need a server that keeps track of it centrally. That's why the solutions you have found so far rely on having a model, presumably backed with a table.

Rails: How to bind large table to a list [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am new to rails, most of my experience is with desktop (Windows) GUI.
In Windows it is possible to bind s a listview to a database table.
the GUI component hold a only the visible rows of the large table.
if the user scroll up/down to rows not in view, the control do a "behind the
scenes" query in database to get the new rows to be displayed.
That allows the GUI to map arbitrary large tables with constance memory usage.
I am sure there must be a similar technique for rails, most likely with the aid of
JQuery but I failed to find it.
I assume the terminology is different is the web world
I would recommend a combination of the will_paginate gem, AJAX, and some javascript framework (jQuery, prototype, AngularJS, etc.). You can use will_paginate to render the first page, and then as the user scrolls down, monitor the scroll progress and load more records. Here's a link to get you started.
I ended up using select2 which did exactly what I was going for

How can I get retrospective info on how often each of my outputcache fires? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I'd like the ability to find out how often each output attribute/filter is being applied, so I need per action granularity and I would like my solution to be as efficient/scalable as possible. The perfmon counters (application-wide) (as answered below) are very handy, but I'd like the per action granularity.
I'd be open for a database solution, but it's not preferred, if I went down this route, how would I insert into the database (for when a response is cached), would I have to subclass Outputcache, and write some code in the constructor?
I'd also be open for logging something out to a file? But again it looks like I'd need to subclass.
I'd also be open to Google analytics type approaches, whereby the user response get's it back.
Is there a way to put a 'cached' marker in my http header? This could be used as an identifier as well.
You can use the ASP.Net Applications perf counters. The ones relevant to your question are:
Output Cache Entries
Output Cache Hit Ratio
Output Cache Hits
Output Cache Misses
You can use perfmon's data collector feature to collect these perf counters for you as your application runs.
These are per-app, so you won't get the per-action granularity you ask for.

Resources