formtastic - Rails 4 has_many view -
formtastic - Rails 4 has_many view -
in model gainloss has many checks, , need create several checks before submiting gainloss model in form. creating collection adding json objects , submiting form. best way in rails ? hint: im using formtastic.
class gainloss < activerecord::base self.table_name = "cashflow" has_many :operations has_many :checks belongs_to :account end class check < activerecord::base belongs_to :gainloss end
_form.html.erb
<%= semantic_form_for @gainloss |f| %> <%= f.inputs %> <%= f.input :date, :as => :date_picker, :required => true%> <%= f.input :gain, :as => :radio, :collection => [['in',true],['out',false]], :label => 'tx type'%> <%= f.input :description %> <%= f.input :account, :collection => account.all %> <%= f.input :cash %> <% end %> <%= f.semantic_fields_for :checks |check| %> <%= check.inputs :date, :bank, :number, :amount, :due, :input_html => { :class => 'form-inline'} %> <% end%> <%= f.actions %> <%= f.action :submit, :as => :button , :button_html => { :class => "btn btn-primary" }, :label => 'guardar' %> <%= f.action :cancel, :as => :link, :button_html => { :class => "btn btn-default" }, :label => 'cancelar' %> <% end %> <% end %>
ruby-on-rails-4 formtastic
Comments
Post a Comment