Tag: forms助手

在rails中,是否使用表单助手?

在rails中,是否建议使用表单助手? 在内部,一切都归结为普通的html然后为什么不直接写html? 在编写直接html时,性能显然会比使用帮助程序更好。 使用表单助手像惯例或铁轨开发人员必须遵循的东西?

Ruby on Rails助手打印出奇怪的东西

我想创建一个帮助程序,它通过用户社区列表进行迭代,并创建与可用社区数量一样多的缩略图。 所以我创建了这两个辅助方法 def print_admined_group_thumbs @user_groups_hash[:admined_groups].each { |group_hash| name = group_hash[:name] group_id = group_hash[:group_id] photo = group_hash[:photo] members_count = group_hash[:members_count].to_i concat(get_group_thumbnail_html(group_id, name, members_count, photo)) } end # creates a small preview for the selected comunity group def get_group_thumbnail_html(group_id, name, members_count, photo) content_tag(:div, :class => “col-md-55”) do concat(content_tag( :div, :class => ‘thumbnail’) do concat(content_tag(:div, :class => ‘image […]

如何在Rails中使用RESTful路由创建删除表单。

我正在尝试创建一个表单,用作控制器上destroy方法的确认。 在我的路线中,我有: resources :leagues do get ‘delete’, :on => :member end 在我的delete.html.erb中,我有以下内容: {:method => :delete} do |form| %> ‘cancel’ %> current_league是一个由以下内容定义的辅助函数: def current_league @current_league ||= League.find_by_id(params[:id]) end 所以问题在于生成的表单只编辑联盟模型,如form method =“post”所示。 我怎样才能解决这个问题?

包含rails form helper中的bootstrap role属性

Twitter Bootstrap具有表单的此角色属性: 如何在Rails表单助手中包含角色属性? 我试过这个,但它不起作用:

为什么check_box表单助手会生成两个复选框,一个隐藏?

此代码:= form_fo:store_products do | f | = f.check_box:track_inventory 创建这个HTML: 第一个隐藏元素的原因是什么?

rails如何决定使用PUT或POST方法呈现表单?

Rails生成一个表单部分,可以在get动作呈现的页面和新动作呈现的页面上使用。 如果是前者,则将表单的方法设置为PUT,如果后者将表单的操作设置为POST。 rails如何决定使用哪种方法?