在一个页面上将params从一个页面传递给另一个ruby on rails helper方法

时间:2014-05-15 21:13:09

标签: ruby-on-rails devise

我已经安装了学生型号

在index.html.haml页面中我有这样的视图

  .span10
    -@brands.each do |brand|
      .row
        .span4.text-center
          =image_tag brand.image_url if brand.image?
        .span2
          %h2=brand.name
        .span4{style: "position:relative; height: 200px; text-align:center;"}
          Requirements
          %h5=brand.requirement
          %div{style: "position: absolute; bottom: 40px; margin-left: auto; margin-right: auto; width: 100%;"}
          =link_to t('slide2.apply_here'), new_student_registration_path(:brand => brand.id),class: "button-component", style: "font-size: 14px; padding: 10px 50px;"

请关注link_to

我将品牌ID传递给new_student_registration路径

这是我的学生注册管理员

class Students::RegistrationsController < Devise::RegistrationsController

  def after_sign_up_path_for(resource)
    '/events/new'
    brand #working on 
  end 

  def after_inactive_sign_up_path(resource)
    '/events/new'
    brand #working on 
  end 

  def brand
    id = params[:brand]
    @brand = Brand.find(id)
  end 
  helper_method :brand 
end

我有一个品牌帮手方法,它从link_to抓取params,我用它来找到一个特定的品牌。

我将它传递到视图中的注册页面以在模型上呈现图片

.row
  .span4
    .accordion#picture_accordion.left
    =image_tag brand.image_url
    %h3=brand.name

我的应用程序控制器中有这个

  def after_sign_in_path_for(resource)
    '/events/new'
  end 

在有人登录或注册后,我指示他们events/new

我想要的是将品牌传递给活动/新品!所以我可以将其再次放入事件/新

.row
  .span4
    .accordion#picture_accordion.left
    =image_tag brand.image_url
    %h3=brand.name

我继续查看我的注册控制器,如何将我的帮助方法的返回值传递给后注册路径方法?我觉得这可行。但是我不知道如何将我的帮助方法的相同返回值传递给我的应用程序控制器中的登录后方法?

非常感谢任何帮助!

0 个答案:

没有答案
相关问题