I get the error :
undefined local variable or method `url_to_submit_event'
when i'm trying to access an helper method from a form in my html.haml.
The html looks like this (the method i'm trying to call is url_to_submit_event) :
myproject/app/views/myengine/form.html.haml :
= form_for @event, url: url_to_submit_event(@event) do |f|
.row
.col-md-12.no-padding
.whitebg.padding15
.form-group.user-info-block.required
= f.label :title, t('myght_default_events.events.form.title'), class: 'control-label'
= f.text_field :title, class: 'form-control'
and the helper goes like this :
myproject/app/helpers/myengine/event_helper.rb :
module MyghtDefaultEvents
module EventHelper
def url_to_submit_event(event)
if event.new_record?
myght_default_events.events_new_path
else
myght_default_events.events_update_path(event.id)
end
end
end
end
At the moment i've tried to add my helper and my method manually in my event_controller but it doesn't work. I've already used a helper the same way and I see no difference in the code, do you have any idea what can be missing here?
My events are in an engine outside of this project but i've made the links between the two projects already, here is the controller just in case :
myengine/app/controllers/myengine/events_controller :
require_dependency "myght_default_events/application_controller"
module MyghtDefaultEvents #:nodoc:
class EventsController < ApplicationController #:nodoc:
before_action :set_event, only: [:edit, :update, :destroy]
*various methods*
end
end
Usually naming it correctly is enough to access it from views so I don't get why I have an error here.