Search code examples
ruby-on-railsruby-on-rails-5ckeditor4.x

cant access nested params from ckeditor gem


I am trying to access a nested param put in by the ckeditor gem. I can't seem to get to them. I can access other nested params.

Here are my params:

    {"utf8"=>"✓",
 "authenticity_token"=>"token==",
 "task"=>
  {"subject"=>"(Quote Requested) LT Quote",
   "description"=>"For sample",
   "problem_on"=>"2019 June 21",
   "due_on"=>"2019 June 28",
   "job_id"=>"121",
   "lmi_host_id"=>"0",
   "assigned_to_id"=>"104",
   "priority"=>"Medium",
   "task_class_id"=>"2"},
 "task_template"=>{"title"=>""},
 "note"=>{"{:class=>\"notes\", :ckeditor=>{:language=>\"us\"}}"=>"<p>test test<strong>setset<em>testste</em></strong></p>\r\n"},
 "bill_hours"=>"0",
 "bill_minutes"=>"0",
 "nonbill_hours"=>"0",
 "nonbill_minutes"=>"0",
 "cat_type_id"=>"",
 "activity"=>{"location_id"=>"", "location_modifier_id"=>"", "review"=>"0", "telecommute"=>"0"},
 "commit"=>"Submit",
 "id"=>"172330"}

I can access

params[:activity][:location_id] and params[:task][:subject] as examples.

When i try to access anything under

params[:note]

I get nil returned.

params[:note]

returns the following:

<ActionController::Parameters {"{:class=>\"notes\", :ckeditor=>{:language=>\"us\"}}"=>"<p>test test<strong>setset<em>testste</em></strong></p>\r\n"} permitted: true>

And i need to find a way to get <p>test test<strong>setset<em>testste</em></strong></p>\r\nout of the params

Thanks for the help!


Solution

  • The problem is from the client

    {"{:class=>\"notes\", :ckeditor=>{:language=>\"us\"}}"=>"<p>test test<strong>setset<em>testste</em></strong></p>\r\n"}
    

    looks very strange because this the key "{:class=>\"notes\", :ckeditor=>{:language=>\"us\"}}" to access the value you need! i think you need to check the client side why it sends it like that