如何实现多步向导

时间:2014-04-24 10:15:16

标签: ruby ruby-on-rails-3 ruby-on-rails-4

    here i am having three controller Eforms,sprints,efforts

    class EformsController < ApplicationController
      # GET /eforms
      # GET /eforms.json
      def index
        @eforms = Eform.all

        respond_to do |format|
          format.html # index.html.erb
          format.json { render json: @eforms }
        end
      end

      # GET /eforms/1
      # GET /eforms/1.json
      def show
        @eform = Eform.find(params[:id])

        respond_to do |format|
          format.html # show.html.erb
          format.json { render json: @eform }
        end
      end

      # GET /eforms/new
      # GET /eforms/new.json
      def new
        @eform = Eform.new

        respond_to do |format|
          format.html # new.html.erb
          format.json { render json: @eform }
        end
      end

      # GET /eforms/1/edit
      def edit
        @eform = Eform.find(params[:id])
      end

      # POST /eforms
      # POST /eforms.json
      def create
        @eform = Eform.new(params[:eform])

        respond_to do |format|
          if @eform.save
            format.html { redirect_to @eform, notice: 'Eform was successfully created.' }
            format.json { render json: @eform, status: :created, location: @eform }
          else
            format.html { render action: "new" }
            format.json { render json: @eform.errors, status: :unprocessable_entity }
          end
        end
      end

      # PUT /eforms/1
      # PUT /eforms/1.json
      def update
        @eform = Eform.find(params[:id])

        respond_to do |format|
          if @eform.update_attributes(params[:eform])
            format.html { redirect_to @eform, notice: 'Eform was successfully updated.' }
            format.json { head :no_content }
          else
            format.html { render action: "edit" }
            format.json { render json: @eform.errors, status: :unprocessable_entity }
          end
        end
      end

      # DELETE /eforms/1
      # DELETE /eforms/1.json
      def destroy
        @eform = Eform.find(params[:id])
        @eform.destroy

        respond_to do |format|
          format.html { redirect_to eforms_url }
          format.json { head :no_content }
        end
      end
    end




    class SprintsController < ApplicationController
      # GET /sprints
      # GET /sprints.json
      def index
        @sprints = Sprint.all




        respond_to do |format|
       format.html # index.html.erb

       format.json { render json: @sprints }
     end
    end

      # GET /sprints/1
      # GET /sprints/1.json
      def show
        @sprint = Sprint.find(params[:id])

        respond_to do |format|
      format.html # show.html.erb
      format.json { render json: @sprint }
    end
    end

      # GET /sprints/new
      # GET /sprints/new.json
      def new
        @sprint = Sprint.new

        respond_to do |format|
                      format.html # new.html.erb
                      format.json { render json: @sprint }
                    end
                  end

      # GET /sprints/1/edit
      def edit
        @sprint = Sprint.find(params[:id])
      end

      # POST /sprints
      # POST /sprints.json
      def create
        @sprint = Sprint.new(params[:sprint])

        respond_to do |format|
          if @sprint.save
            format.html { redirect_to @sprint, notice: 'Sprint was successfully created.' }
            format.json { render json: @sprint, status: :created, location: @sprint }
          else
            format.html { render action: "new" }
            format.json { render json: @sprint.errors, status: :unprocessable_entity }
          end
        end
      end

      # PUT /sprints/1
      # PUT /sprints/1.json
      def update
        @sprint = Sprint.find(params[:id])

        respond_to do |format|
          if @sprint.update_attributes(params[:sprint])
            format.html { redirect_to @sprint, notice: 'Sprint was successfully updated.' }
            format.json { head :no_content }
          else
            format.html { render action: "edit" }
            format.json { render json: @sprint.errors, status: :unprocessable_entity }
          end
        end
      end

      # DELETE /sprints/1
      # DELETE /sprints/1.json
      def destroy
        @sprint = Sprint.find(params[:id])
        @sprint.destroy

        respond_to do |format|
          format.html { redirect_to sprints_url }
          format.json { head :no_content }
        end
      end
    end



class EffortsController < ApplicationController
  # GET /efforts
  # GET /efforts.json
  def index
    @efforts = Effort.all

    respond_to do |format|
      format.html # index.html.erb
      format.json { render json: @efforts }
    end
  end

  # GET /efforts/1
  # GET /efforts/1.json
  def show
    @effort = Effort.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.json { render json: @effort }
    end
  end

  # GET /efforts/new
  # GET /efforts/new.json
  def new
    @effort = Effort.new

    respond_to do |format|
      format.html # new.html.erb
      format.json { render json: @effort }
    end
  end

  # GET /efforts/1/edit
  def edit
    @effort = Effort.find(params[:id])
  end

  # POST /efforts
  # POST /efforts.json
  def create
    @effort = Effort.new(params[:effort])

    respond_to do |format|
      if @effort.save
        format.html { redirect_to @effort, notice: 'Effort was successfully created.' }
        format.json { render json: @effort, status: :created, location: @effort }
      else
        format.html { render action: "new" }
        format.json { render json: @effort.errors, status: :unprocessable_entity }
      end
    end
  end

  # PUT /efforts/1
  # PUT /efforts/1.json
  def update
    @effort = Effort.find(params[:id])

    respond_to do |format|
      if @effort.update_attributes(params[:effort])
        format.html { redirect_to @effort, notice: 'Effort was successfully updated.' }
        format.json { head :no_content }
      else
        format.html { render action: "edit" }
        format.json { render json: @effort.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /efforts/1
  # DELETE /efforts/1.json
  def destroy
    @effort = Effort.find(params[:id])
    @effort.destroy

    respond_to do |format|
      format.html { redirect_to efforts_url }
      format.json { head :no_content }
    end
  end
end

这里eform是第一页。用户应该在eform中输入比重定向到sprint的值。 eform应该处于保持状态,因为eform_id是sprint中的外键。类似地,在用户控制器填充冲刺后应该重定向到努力。但是sprint内容应该暂停,因为sprint_id是努力的外键....这是我的疑问请解决它我很麻烦我是ruby的新手..

0 个答案:

没有答案