Dynamic Paths in Helper

basically you need to transform the class name of the model into something pointing to the correct path. model_name = m.class.to_s.underscore And then use it to call the appropriate path methods link_to “edit”, send(“edit_#{model_name}_path”, m) As an aside, you don’t need to put the link_tos in #{} because that function simply returns a string.

Changing type of ActiveRecord Class in Rails with Single Table Inheritance

Steve’s answer works but since the instance is of class BaseUser when save is called, validations and callbacks defined in User will not run. You’ll probably want to convert the instance using the becomes method: user = BaseUser.where(email: “[email protected]”).first_or_initialize user = user.becomes(User) # convert to instance from BaseUser to User user.type = “User” user.save!

rails best practices where to place unobtrusive javascript

I do not think there is one best practice, but I’ll let you know what I do. I have a series of js files each for with their own purpose in the public/javascripts/ directory. Some examples could be utility.js chat.js shopping_basket.js and so on. I use asset packager and define one big fat collection for … Read more

How do I set up a Rails Angular project to test JS?

You can use teaspoon it runs your favorite test suite (default is jasmine) and they have a wiki to integrate with angular. Teaspoon integrates with the asset pipeline, so you can throw all the angular gems in there and require them in the teaspoon generated spec_helper.js. The other cool thing is: they have a guard … Read more

techhipbettruvabetnorabahisbahis forumueduedueduedusedusedueduedusedusedus