Alexey Poimtsev
Alexey Poimtsev

Reputation: 2847

formtastic - :string field value as Array and not found-s

is there any possibility to send from formtastic form value of :string field like

- semantic_form_for :project do |form|
 - form.inputs do
  = form.input :task_ids, :as => :string

as Array? Currently value of this field is sending as String and i'd like to no parse this string in controller.

Also, could you give me idea - if task with submitted id is not found - what is best way to catch this situation - validation in controller or what?

Upvotes: 0

Views: 719

Answers (2)

Alexey Poimtsev
Alexey Poimtsev

Reputation: 2847

I've solved this issue with creation attribute accessor for task_ids

Upvotes: 1

Andrius
Andrius

Reputation: 2818

One way you could handle this is by using :as => :check_boxes or :as => :select with :tasks associations directly this would have added benefit of being user friendly. If you insist on using task_ids though, it's probably best to override task_ids= method. There you could handle parsing data and validating.

Upvotes: 0

Related Questions