Controller Rails 4.1:未调用控制器操作

Controller Rails 4.1:未调用控制器操作,controller,ruby-on-rails-4.1,Controller,Ruby On Rails 4.1,我有以下控制器代码,用于在同一控制器中呈现另一个控制器操作: def create @school_application = SchoolApplication.new(school_application_params) @school_application.program_cost = @school_application.calculate_cost_to_charge(params[:school_application][:program], para

我有以下控制器代码,用于在同一控制器中呈现另一个控制器操作:

  def create
    @school_application = SchoolApplication.new(school_application_params)
    @school_application.program_cost = @school_application.calculate_cost_to_charge(params[:school_application][:program],     params[:school_application][:duration])
    if @school_application.save
      Rails.logger.debug("Hey mufugga")
      render action: 'view'
    else  
      flash.now[:error] = "There was a problem with your application"
      render action: "new"
    end
 end
render action:'view'
被调用为适当的视图时,
view.html.haml
被调用,但是我的
Rails.logger.debug
行不会打印在我的服务器日志中,并且所有其他变量都不会在我的视图中设置(使用这些变量)。有人知道发生了什么事吗?下面是视图控制器方法

  def view
   Rails.logger.debug("Hello")
   @school_application =SchoolApplication.find(params[:id])
   Rails.logger.debug(@school_application)
   @sevic = SchoolApplication.sevic(@school_application.sevic)
   @cost = @school_application.program_cost.to_i + @sevic.to_i 
   Rails.logger.debug(@cost)
   session[:cost] = @cost
  end
注意:以下是Rails对创建请求的lolg响应以及成功和未成功的
记录器输出:

Started POST "/application/new" for 127.0.0.1 at 2014-08-29 13:56:56 -0700
Processing by SchoolApplicationsController#create as HTML
  Parameters: {"utf8"=>"✓",   "authenticity_token"=>"cl9CZCC2numQ1aCckWkXizXESByZxOFrb/pl8vhA6YQ=", "school_application"=>{"first_name"=>"d", "family_name"=>"dfg", "sevic"=>"1", "unaccompanied_minor_option"=>"1", "I_20"=>"1", "fls_center"=>"4", "start_date"=>"2014-07-30", "duration"=>"1", "housing_type"=>"22", "health_insurance"=>"1", "transfer_student"=>"1", "comments"=>"d", "gender"=>"dfg", "address"=>"d", "city_state_province"=>"d", "postal_code"=>"d", "country"=>"d", "phone_number"=>"d", "email"=>"d", "date_of_birth"=>"2014-08-05", "arrival_airport"=>"3", "read_everything"=>"1", "country_of_birth"=>"d", "country_of_citizenship"=>"d", "work_with_ad"=>"1", "pay_application_fee_or_full"=>"1", "agency"=>"d", "fax_number"=>"d", "program"=>"7"}, "commit"=>"Continue"}
Unpermitted parameters: unaccompanied_minor_option
  PricePlan Load (0.3ms)  SELECT  "price_plans".* FROM "price_plans"  WHERE "price_plans"."program_id" = 7  ORDER BY "price_plans"."id" ASC LIMIT 1000
   (0.1ms)  BEGIN
  SQL (0.4ms)  INSERT INTO "school_applications" ("I_20", "address", "agency",     "arrival_airport", "city_state_province", "comments", "country", "country_of_birth", "country_of_citizenship", "created_at", "date_of_birth", "duration", "email", "family_name", "fax_number", "first_name", "fls_center", "gender", "health_insurance", "housing_type",  "pay_application_fee_or_full", "phone_number", "postal_code", "program", "program_cost", "    read_everything", "sevic", "start_date", "transfer_student", "updated_at", "work_with_ad")   VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31) RETURNING "id"  [["I_20", "t"], ["address", "d"], ["agency", "d"], ["arrival_airport", "3"], ["city_state_province", "d"], ["comments", "d"], ["country", "d"], ["country_of_birth", "d"], ["country_of_citizenship", "d"], ["created_at", "2014-08-29 20:56:56.726865"], ["date_of_birth", "2014-08-05"], ["duration", 1], ["email", "d"], ["family_name", "dfg"], ["fax_number", "d"], ["first_name", "d"], ["fls_center", "4"], ["gender", "dfg"], ["health_insurance", "t"], ["housing_type", "22"], ["pay_application_fee_or_full", "t"], ["phone_number", "d"], ["postal_code", "d"], ["program", "7"], ["program_cost", "475.00"], ["read_everything", "t"], ["sevic", "t"], ["start_date", "2014-07-30"], ["transfer_student", "t"], ["updated_at", "2014-08-29 20:56:56.726865"], ["work_with_ad", "t"]]
   (0.8ms)  COMMIT
Hey mufugga
  Rendered application/view.html.haml within layouts/application (0.3ms)
  Rendered shared/_top_nav.html.haml (0.1ms)
  Rendered shared/_footer.html.haml (0.4ms)
Completed 200 OK in 40ms (Views: 15.8ms | ActiveRecord: 5.1ms)

所以我误解了
render:action=>
的确切功能。在重温rails指南之后,我意识到它只渲染与该操作相对应的视图,这不是我预期的行为,因此没有调用与我渲染的视图相对应的控制器操作

我想做的是通过调用
redirect\u to
到包含我正在调用的操作的url,从而从服务器创建所需的响应