ruby-on-railsweb-application-design

How to manually change what the users see through a back-end of a Rails app?


I am designing a voting application. Generally I want my users to have just a few views:

View 1: Please wait

View 2: Text of a question

View 3: Text of a question + voting buttons bellow it

View 4: Text of a question + “You voted… (for/against/abstained)” message below it

restart from view 1

The app will be used during a meeting, where agenda items will be voted on. The users have tablets and there is a live speaker. Before the speaker has asked the first question, the users will only see view 1 on their devices. The speaker/admin initiates view 2 and at the same time reads the question out loud. Speaker/admin initiates view 3 to start the voting. The users vote and when the admin sees that the voting is complete (they have a back-end which reports if all eligible users have voted), they restart the cycle. The thing is that the transfer from one view to the other is sometimes initiated by the users and (more often) - by the admin.

Because I am new to Ruby and Rails, so far my experience is that in a Rails app, you have some links, which trigger actions, which render views. But how do I change the views for/on behalf of the users? How do I do this, when the user does not initiate any action, but the admin decides when the view should be changed?

My assumption is that in the admin back-end there must be some buttons, which trigger actions, which render certain views but I am missing the link of how to render the views for the users and not for the admin, who is triggering the actions.


Solution

  • You will have to use AJAX for sending check calls after a particular duration, you can call the function in a simple JavaScript timer block. The controller can have some status and as soon as it changes, change the ajax response that you are throwing back and on the basis of response java script will change the user view without his prompt just by admins change. hope it helps, ask if something is not clear.