如何在Ruby on Rails中隐藏标签

时间:2014-10-03 21:47:49

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

我正在尝试创建一个动态页面并使用CoffeScript

class Requistion < ActiveRecord::Base
end

class RequistionsController < ApplicationController
  def show
    @requistion = Requistion.find(params[:id])
  end

  def create
    @requistion = Requistion.new(user_params)
    @requistion.save
  end

  def index
    @requistions = Requistion.all
  end


  def new
    @requistion = Requistion.new
  end

  private
  def user_params
        params.require(:requistion).permit(:object)
  end
end

查看代码:

<%= f.label :info, :'text',  class: "col-md-4 control-label" %>
<%= f.text_field :info,  class: "form-control" %>

下面是JQuery代码。

$('#class_info').parent().hide()

该字段是隐藏的,但标签不是。问题是什么?

1 个答案:

答案 0 :(得分:4)

查看代码:

<%= f.label :info, :'text',  class: "col-md-4 control-label hidden" %>
<%= f.text_field :info,  class: "form-control hidden" %>

CSS:

.hidden{
  display: none;
}