Please could you help me to think about how best to layout a form.
I have a series of checklist boolean questions (for example, do you want data?). If the answer is yes, I want to show questions further relating to data.
I have a form with the series of boolean questions and another form with the follow up questions to be shown if the answer is true at the top level.
How do I go about revealing the detailed follow up questions if the answer at the top is true?
I tried if true then -- a link to the follow up form, but I'm either expressing it incorrectly or approaching the layout all wrong. I've seen some questions in this post describing methods to help with the reveal, but I don't follow the reasoning behind why.
Thank you.
It sounds like you will need a large nested form, or multiple smaller forms.
You have 2 simple options:
Use Javascript to hide/show nested questions when some checks a box. here is an example: https://stackoverflow.com/a/6358754/1536309
Create a wizard! think about how your form can be completed in a few stages instead of at one time. https://github.com/schneems/wicked this is a good gem for building wizards. You could have each checkbox and its related information be a stage in the wizard, then the last page would submit the entire form contents.
Related
I have a Request model and a nested Keyword model in my system. I want to click 'Add Keyword' button or link in Request index page and want to fill the Keyword informations in a popbox. I don't want to open a new page.
At first, I have used Ryan Bates' Nested Model Form. But my models are very specific and thus they make the page very long. I don't want to make page so much vertical. I just don't want to scroll up-down all the time.
I've looked around so much, there are a lot of questions here, too. But I didn't find the specific solution. Can you help me, please? Thanks.
I have a problem about the nested forms, which I've survey for some possible solutions (Nested form gem, Railscasts) but still have no idea to implement it.
My question is totally based on the solutions above, so please read it if you need :)
Now, my question is:
If i want to add/edit "only one" Question(and it's Answers) per page after I "create/edit" a Survey how could I make it?
In other words, there is only one Question(but could have dynamic numbers of Answers) fields, in the "create/edit" Survey page.
And how to make
add another question,
edit previous question or
remove current question
functions.
I've try to solve this by 2 ways, one is using javascript to hide the previous question each time I add a new one, but in this schema, I can't make my way to edit the existed question.
Another is using Ajax, but ... I have no idea with it.
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!
I have a model with many fields (nearly 40). The client wants the fields divided among multiple screens. The model also has a few has_manys that should look like they are part of the same model.
How can one divide the model, and what are the tradeoffs among the ways to do it?
I see a couple of possibilities:
1) Use JavaScript to show and hide parts of the form. I think I can make that one work.
2) Use forms that submit to different actions. Can form_for be used with appropriate options?
I'm looking for other ideas too.
Check out acts as state machine. You can use this to create wizards and whatnot.
Having reread your question, I think Javascript is really what you're looking for. Check out jQuery UI, they've got a tab component that will probably help.
I would check out the ActsAsWizard plugin. Makes doing a wizard like this extremely simple.
Check out the readme it is excellent.
I asked a question earlier, and got an excellent response, but, being a newbie to Rails and still getting the basics down, I need someone to show me how to set up some scaffolding for the situation that Hates_ was nice enough to outline for me. I've set up my application and whatnot, but I basically want to have, for example purposes:
A "Stories" table, for a list of stories
A "Pages" table, for a list of pages that can be attached to stories
A "LinkedPages" table, to link one page to multiple other pages
The idea is that users can create Stories. Stories have Pages. Pages link to other Pages in a branching sort of way, and Hates_ suggested using a LinkedPages table to assist the process of determining which pages link to which other pages.
If someone could use the example models Hates_ provided on the link above (or give me better ones if needed), and just show me how to get this started, I'd be extremely grateful. Rails has had the highest initial learning curve of any programming or scripting language I've learned in the past, I'm just starting to understand many of the basics.
Thanks in advance!
Here is an updated fast paced video that quickly presents some of the wicked sweet features in Rails via a somewhat contrived Blog tutorial.
http://media.rubyonrails.org/video/rails_blog_2.mov
The presenter crams a lot of information into a very short time frame and does paste in some prepared code from time to time, but over all he hits on many of the key features.
He explains how to set up scaffolding as well in about probably the last 5 mins or so.