What helper can I use in model to populate html code as string in view?
This is the method I currently use in my model:
def state_country_name
"#{self.name} (#{self.country.name})"
end
I want to wrapp {self.country.name} inside a span, with class: pull-right.
I have already tried:
def state_country_name
"#{self.name} #{helpers.content_tag(:span, self.country.name, class: "pull-right")}"
end
def helpers
ActionController::Base.helpers
end
Result:
London <span>England</span>
I use the autocomplete-rails4-gem and this is my form input:
= f.input :city_name, :url => autocomplete_city_name_companies_path, :as => :autocomplete, :id_element => "#company_city_id", input_html: {:value => @company.city.name, class: 'form-control'}
Code for my autocomplete_city_name_companies action:
autocomplete :city, :name, :full => false, :display_value => :state_country_name, :extra_data => [:state_id]