I wanna achieve the following to display in rails app:
Product instance => "product"
ProductCustomer instance => "product customer"
so I could do
<%= form_for([commentable, Comment.new]) do |f| %>
<%= f.text_field :body, class: "form-control", id: "comment-text-area-#{commentable.id}",
placeholder: "Ask something about the #{commentable.class.name.split(/(?=[A-Z])/).join(' ').downcase }" %>
......
<% end %>
At the moment I'm using the following which works in all cases:
p = Product.new
p.class.name.split(/(?=[A-Z])/).join(' ').downcase
pc = ProductCustomer.new
pc.class.name.split(/(?=[A-Z])/).join(' ').downcase
My problem is that it seems to be too complex. I guess there should be a better way. Any ideas?