Evaluation Form Creation - ruby-on-rails

I'm taking a "cloud computing" course and have a few problems that I am trying to work through for the final project. I'll preface this with saying that i know nothing about this subject, and the few powerpoints I got off my online class don't really seem to point me in the right direction.
Basically what i need to do is have a page that allows a user to create a evaluation form. I have a general idea how to do it but I don't even know where to start in rails, I was hoping there was some stuff that Rails would do for me that might make it easier.
My assumption is that I could create a form that would allow entries for section headings.
Then when one occurs I need to allow actual question entries. then the user has the option of adding questions for the section. Then the user may add another heading, and questions.
When this "process" is complete, I need to allow a 2nd user to actually use the form for entries.
I'm assuming I somehow need to make a "string' object that will hold the text that I'm setting up, and then it sets up entries for each question.
I'm clueless where to start, I'll probably be asking a lot of questions. I don't want the solution I just need to get pointers, heading in the right direction.
the first step I'm thinking is finding a way to allow a "command" to do the equivalent of this but in the browser from another form:
rails generate scaffold Evaluation Topic:string rating:string comments:string
Is there a way to "create" a scaffold of a form using rails in a web browser?

It seems to me that you are mostly concerned with created forms using Rails.
Railscasts has some awesome tutorials on forms: Railscasts
After viewing some of those, you should see that Rails follows an MVC policy (more information here).
Since you mentioned the scaffold, it creates several controller actions. One of those is "new" (also "edit") which I believe would be the equivalent of creating the evaluation form.
You could then create a controller action(s) for users to fill out the evaluation form.
These links should clear up a few of your questions and get you used to the rails terminology for better questions later.
Good Luck!

Related

Could use some advice on making a calculation page in ruby on rails

I have studied rails for some time now and everywhere I look, the books teach you how to create blog like applications.
But now I would like to create an application, where you have for instance a form to choose how many calculations I want to do and a form to choose what type of calculations should they be.
After that I would insert numbers into newly created forms and the app would calculate them and print the anwer.
Now I really don't see, how I can do this without putting the numbers inserted into a DB and then calculating with them, printing the answer and then deleting the DB entries.
Seems like a very clumsy way doing it.
Anyone have some advice on how to approach this problem?
The way I see this is: you create a dropdown with possible calculation options and enhance it with javascript (or ajax if it is complicated) to insert needed fields. Then you have all the data in one form, you send it to action, do calculations and displays them.

Create rails form to modify database values - but not with a model

I'm trying to create a universal settings page for my rails app and I have no idea where to start. I know there are several gems that make it simple, and I've read the docs. They enable you to do something like Settings.color = "red" and your settings for color will be red! But, how do I turn this into a form, connected to the database, that the users can then change the values?
Ideally, we need a few settings, I know one of them will be a select box where they have numerous options but only one can be chosen at a time (think Active, Suspended, Disabled, etc).
This isn't really something that a model should be used for because its not a thing, right? I'm totally lost. I can make a database table, but without a model or a controller I have no idea how to just "make a form" that saves into the database - and then how do I get those values out?
Edit: The plug ins I'm referring to are similar to https://github.com/Squeegy/rails-settings and its variants. They show you how to hard code settings which is great, but don't go into how to create a form or any of the back end stuff to make it work. It's not a model so I'm totally clueless here. There's no scaffolding to work off of.
rails-settings is model based, as the readme specifically states that.
So you'd just do as per any other model-based form.

rails best practice for a multistep form?

I want to create a mutlistep form in Rails 3. I've watched the railscasts episode on it, but I did not feel like he was using the best practice when creating the form. I felt like it was a sloppy way to accomplish the task. What is the best way to create a multistep form using the best practices in rails?
Your question is a little hard to answer without more information, and a true answer would be a detailed tutorial (like a Railscast) rather than a SO answer, but here's some thoughts to get you on your way.
There are two major approaches to multistep forms:
Use Javascript to display the form bit by bit
Create separate views and use create/update or similar to route the user from one to the next.
There are advantages to each method, depending on whether you want to support javascript, and what your requirements are about saving data in between sections.
Advantages of 1
Faster for the user to navigate from section to section (javascript hide/show is instantaneous)
Data is easily accessible is the user wants to refer to an earlier section
Simpler controller actions
Disadvantages of 1
Will not work for users who are not running javascript (and no progressive enhancement is really possible here other than displaying the form as a huge chunk).
Will require you to provide javascript-based navigation to move from section to section (only a disadvantage if you're new to .js)
Will require AJAX if you want to save the user's information between steps.
Without AJAX and javascript, the user is at the risk of losing a lot of entry if the user accidentally pressing the back button, etc.

Displaying a Form, Perform Calculations, and Displaying Results in Ruby on Rails

Is there a good barebones rails app that displays one form (with some selectors/text fields), performs some calculation on the entries, and displays the results of the calculations?
For some reason a few hours of searching has yet to result in a complete example that does the entire workflow itself - often the calculations are passed off to another site.
Essentially what I'm looking for is a simple Rails HTML Form processor...
Thank you!
Doug
I would actually recommend picking up a Rails book and digging in to thoroughly understand the architecture. There are a lot of examples out there of setting up blogs but most end up showing you scaffolding which (in my experience) is typically useless on real projects.
Nevertheless, Rails does make it fairly simple to process form data (usually params[:my_model] or just the params hash directly) and respond to the client from within the controller action. I suppose in your final solution, the action will make a call to the remote site to "POST" the result or delegate that behavior to a model.
Hopefully some of this answers your concerns and appears less as a RTFM comment. :)

Ruby on Rails simple website layout

I'm learning RoR, I've read some tutorials (railstutorial for the first one),
but I've a problem to define the logic layout of the my first simple website.
The structure is:
When you go to mysite.com you see a welcome page with the signup form or the link for login.
If you signup or you login into the site, you are at mysite.com/dashboard and you see a list of your messages.
You can go to mysite.com/$username and you see a page with a form where you can write a message for the $username.
Stop. That's it. It's very simple, I know, but is for learning.
The problem is this: I'm new to MVC paradigm and I don't know how structure the logic layout of my app. Of course there'll two models: User and Message. But for controllers? And which functions in any controllers? Should I use scaffolding?
Please give me a help, I'm very confused.
Thank you.
Controllers are the logic for the data, so to login/sign-up is really validating/creating a user, if you need to view the users dash board, well that's a look up on the user data so he goes there as well.
The messages, that will be a separate controller that can create/view messages!
As others have pointed out, your controllers contain the logic for your code and invoke views based on that logic by rendering or redirecting to pages. You can define whatever actions you want in your controllers, and then use routes to map a particular URL to a controller action. That being said, Rails gets a lot easier if you "go with the flow" and make some simple assumptions about the actions that could happen. Both your users and your messages represent rows in their respective database tables. There's no much you can do to a row in a database table - you can Create it, Read it, Update it, or Delete it (CRUD). If you define your actions in terms of these four logical actions, Rails lets you generate some easy routes.
You can back into any URL schema that you want, but what you are describing is:
Read the messages that are for a user on the dashboard
Create a message for a user when you go to another page (mysite/username)
Each of these maps to a CRUD action that you should be defining in your controllers.
Agreed also with other advice to simply do a few more tutorials that will probably clear this up.
If you haven't already, read Getting Started with Rails. Look out for the discussion on MVC and scaffolding. Playing around with scaffolding can help you learn where things go and is a great place to start for beginners.
Also, I highly recommend this book: Agile Web Development with Rails. It is very hands on and an easy read.

Resources