formtastic

Insert a non-input row into a Formtasic form

倾然丶 夕夏残阳落幕 提交于 2019-11-27 11:42:56
问题 I am using Formtastic 2.1.1 in Rails 3.2 (with Active Admin) and I want to insert a row into my form that does not have an input field present. Is this possible and what is the syntax in the Formtastic DSL to achieve this? Here's an example: form do |f| f.inputs "Model Info" do f.input :title f.input :published f.input :path end end I'd like to do something like this: form do |f| f.inputs "Model Info" do f.input :title f.input :published f.input :path f.div "This is some important text that

Rails 3, nested multi-level forms and has_many through

≡放荡痞女 提交于 2019-11-27 10:11:50
问题 I'm trying to get it to work but it dosen't! I have class User < ActiveRecord::Base has_many :events, :through => :event_users has_many :event_users accepts_nested_attributes_for :event_users end class Event < ActiveRecord::Base has_many :event_users has_many :users, :through => :event_users accepts_nested_attributes_for :users end class EventUser < ActiveRecord::Base set_table_name :events_users belongs_to :event belongs_to :user accepts_nested_attributes_for :events accepts_nested

Rails Formtastic: adding “data-” field to option tag

拜拜、爱过 提交于 2019-11-26 21:46:27
问题 I have: form.input :duration, as: select, collection: {} I need: <option value="" data-price="XXX"></option> Rails does not support HTML5 data attributes for the option tag. Formtastic suggests to create a helper method for this. Formtastic readme describes how to extend input tags. However, in select_input.rb I can't find any method which would affect the option tag. So, how do I do this? Also, I found enhanced_select gem which does exactly what I need, but I am not able to make it work with