Hi guys

I have many different models and I want to reuse the same code for the
delete button.
So in my helper i have:

def delete_button(item_to_delete)
    button_to t('buttons.delete'), :action => "destroy", :controller
=> item_to_delete.class.to_s.downcase.pluralize
end

Normally i work with paths a la post_path(item_to_destroy) but I cant
find a way of making that work for different models except throwing in
some stupid switch statement which makes the code REALLY ugly..

So the code above throws a route not found error. BUT:
def delete_button(item_to_delete)
    button_to t('buttons.delete'), :action => "new", :controller =>
item_to_delete.class.to_s.downcase.pluralize
end

works just fine.. these are the things that really annoy me about ruby
on rails.

Also.. the most ridiculous thing happens at the moment.. I use the
asset pipeline and after rebooting all javascript code in my file
users.js.coffee doesnt get executed in my browser anymore.. If i put
it in example 'messages.js.coffee' it works just fine. EXACTLY the
same syntax in both files.. I have NO idea why that happens. But
frankly after wasting 1h on that I dont care. Just leave my code in
the wrong file where it works..

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to