Update Array in rails view form

24 views
Skip to first unread message

Vlad Panainte

unread,
Dec 30, 2014, 5:52:18 AM12/30/14
to rubyonra...@googlegroups.com
Hi guys,

I need some help with updating an array using rails view form .

In controller 

def foo_params
    params.require(:foo).permit(:value,:rvalue)
  end

where rvalue is an array. I've tried :rvalue=>[] but no luck


In form I have 
 <%= form_for :foo, url: foo_path(@foo.foo_value, @foo), method: :put, html: {class: 'uk-form'} do |builder| %>
.....
<%= builder.label "rvalue", "Value" %>
<%= builder.text_field "rvalue" , class: "uk-width-1-1" %>

Can you please help?

Thanks

Frederick Cheung

unread,
Dec 30, 2014, 7:37:39 AM12/30/14
to rubyonra...@googlegroups.com


On Tuesday, December 30, 2014 10:52:18 AM UTC, Vlad Panainte wrote:
Hi guys,

I need some help with updating an array using rails view form .

In controller 

def foo_params
    params.require(:foo).permit(:value,:rvalue)
  end

where rvalue is an array. I've tried :rvalue=>[] but no luck


What's the problem? Is strong parameters not permitting the value or something else?

Fred

Hassan Schroeder

unread,
Dec 30, 2014, 11:57:38 AM12/30/14
to rubyonrails-talk
On Tue, Dec 30, 2014 at 2:52 AM, Vlad Panainte <vlad.p...@gmail.com> wrote:

> def foo_params
> params.require(:foo).permit(:value,:rvalue)
> end
>
> where rvalue is an array. I've tried :rvalue=>[] but no luck

> <%= builder.text_field "rvalue" , class: "uk-width-1-1" %>

? Your "rvalue" param is going to be a string.

I don't understand why you expect it to be an array.

--
Hassan Schroeder ------------------------ hassan.s...@gmail.com
http://about.me/hassanschroeder
twitter: @hassan
Reply all
Reply to author
Forward
0 new messages