Class: FormSubmissionsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- FormSubmissionsController
- Defined in:
- lib/generators/install/templates/app/controllers/form_submissions_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /form_submissions POST /form_submissions.json.
-
#destroy ⇒ Object
DELETE /form_submissions/1 DELETE /form_submissions/1.json.
-
#edit ⇒ Object
GET /form_submissions/1/edit.
-
#index ⇒ Object
GET /form_submissions GET /form_submissions.json.
-
#new ⇒ Object
GET /form_submissions/new GET /form_submissions/new.json.
-
#show ⇒ Object
GET /form_submissions/1 GET /form_submissions/1.json.
-
#update ⇒ Object
PUT /form_submissions/1 PUT /form_submissions/1.json.
Instance Method Details
#create ⇒ Object
POST /form_submissions POST /form_submissions.json
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/generators/install/templates/app/controllers/form_submissions_controller.rb', line 43 def create @form_submission = FormSubmission.new(params[:form_submission]) respond_to do |format| if @form_submission.save format.html { redirect_to @form_submission, notice: 'Form submission was successfully created.' } format.json { render json: @form_submission, status: :created, location: @form_submission } else format.html { render action: "new" } format.json { render json: @form_submission.errors, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /form_submissions/1 DELETE /form_submissions/1.json
74 75 76 77 78 79 80 81 82 |
# File 'lib/generators/install/templates/app/controllers/form_submissions_controller.rb', line 74 def destroy @form_submission = FormSubmission.find(params[:id]) @form_submission.destroy respond_to do |format| format.html { redirect_to form_submissions_url } format.json { head :ok } end end |
#edit ⇒ Object
GET /form_submissions/1/edit
37 38 39 |
# File 'lib/generators/install/templates/app/controllers/form_submissions_controller.rb', line 37 def edit @form_submission = FormSubmission.find(params[:id]) end |
#index ⇒ Object
GET /form_submissions GET /form_submissions.json
4 5 6 7 8 9 10 11 12 |
# File 'lib/generators/install/templates/app/controllers/form_submissions_controller.rb', line 4 def index @form = Form.find(params[:form_id]) @form_submissions = FormSubmission.joins(:form_schema).where("form_schemas.form_id = ?", @form.id) respond_to do |format| format.html # index.html.erb format.json { render json: @form_submissions } end end |
#new ⇒ Object
GET /form_submissions/new GET /form_submissions/new.json
26 27 28 29 30 31 32 33 34 |
# File 'lib/generators/install/templates/app/controllers/form_submissions_controller.rb', line 26 def new @form_submission = FormSubmission.new @form_submission.form_schema_id = Form.find(params[:form_id]).form_schemas.first.id respond_to do |format| format.html # new.html.erb format.json { render json: @form_submission } end end |
#show ⇒ Object
GET /form_submissions/1 GET /form_submissions/1.json
16 17 18 19 20 21 22 |
# File 'lib/generators/install/templates/app/controllers/form_submissions_controller.rb', line 16 def show @form_submission = FormSubmission.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @form_submission } end end |
#update ⇒ Object
PUT /form_submissions/1 PUT /form_submissions/1.json
58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/generators/install/templates/app/controllers/form_submissions_controller.rb', line 58 def update @form_submission = FormSubmission.find(params[:id]) respond_to do |format| if @form_submission.update_attributes(params[:form_submission]) format.html { redirect_to @form_submission, notice: 'Form submission was successfully updated.' } format.json { head :ok } else format.html { render action: "edit" } format.json { render json: @form_submission.errors, status: :unprocessable_entity } end end end |