Ruby on Rails Thursday, March 1, 2018

Hassan,


On 2018-03-02 04:21, Hassan Schroeder wrote:
> On Thu, Mar 1, 2018 at 8:10 AM, Philip Rhoades <phil@pricom.com.au>
> wrote:
>
>> <%= b.label + b.radio_button %>
>
>> which actually works in the view but unlike the Checkbox version the
>> data is
>> not saved in the tippers_tips table.
>
> The line above looks a bit iffy to me, but the main question is: what
> do you see in your logs? any error messages?
>
> If not use logging statements (or pry) to inspect the params being
> returned.


Thanks for responding - I see in the log when I edit a Tipper:

Processing by TippersController#update as HTML
Parameters: {"utf8"=>"âœ"",
"authenticity_token"=>"AhTjh08BAh6NALIeQ5yc7qVvjO8S6rnBaCQlsocM6ffiVkKMo2eKaAmP/QBA2Iiu79naCW+Pd8XZsTMbnYbutQ==",
"tipper"=>{"fname"=>"Jocelyn", "tip_ids"=>"1"}, "commit"=>"Update
Tipper", "id"=>"3"}
Tipper Load (0.1ms) SELECT "tippers".* FROM "tippers" WHERE
"tippers"."id" = ? LIMIT ? [["id", 3], ["LIMIT", 1]]
Unpermitted parameter: tip_ids

During the tables generation I did:

rails g migration CreateJoinTableTipTipper tip tipper

and the only two mentions of "tip_ids" is in
app/views/tippers/_form.html.erb :

<div class="field">
<%= f.label "Tip" %><br />
<%= f.collection_radio_buttons( :tip_ids, Tip.all, :id, :teams ) do
|b| %>
<div class="collection-radio-button">
<%= b.radio_button %>
<%= b.label %>
</div>
<% end %>
</div>

and app/controllers/tippers_controller.rb :

params.require(:tipper).permit(:fname, tip_ids:[])

I deleted "[]" since there should be only one tip id returned but that
caused and error . .

Thanks,

Phil.
--
Philip Rhoades

PO Box 896
Cowra NSW 2794
Australia
E-mail: phil@pricom.com.au

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/fd8893daf30eb739c87670a7f1cd9d5b%40pricom.com.au.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment