Question

I am trying to pass variables to a best_in_place display_as custom method. Something like the code below:

<%= best_in_place @track, :forms_metadata,
    type: :date, 
    nil: 'Set Due Date',
    display_as: :this_forms_metadata(@track, form.id),
    path: update_forms_metadata_admin_track_path(@track, form_id: form.id) %>

However, I am getting this error:

syntax error, unexpected '(', expecting ')'

In tracks_controller.rb:

def this_forms_metadata(track, form_id)
  track.forms_metadata[form_id.to_s]["due_date"]
end

Can anyone see what I am doing wrong, or is this even possible?

Thanks for any help.

Was it helpful?

Solution

pass

this_forms_metadata(@track, form.id)

as a method not a symbol. Secondly you cannot use controller method in your view, you should move

this_forms_metadata(@track, form.id)

to helper file and then use it as a method not a symbol. Here is what you need to write in your view

<%= best_in_place @track, :forms_metadata,
 type: :date, 
 nil: 'Set Due Date',
 display_as: this_forms_metadata(@track, form.id),
 path: update_forms_metadata_admin_track_path(@track, form_id: form.id) %>

move your method 'this_forms_metadata' to helper file

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top