Differences between railties and engines in Ruby On Rails 3

Railtie can probably do what you describe, but it may be more desirable to use an engine. The engine can have its own configuration and also acts like a Rails application, since it allows you to include the /app directory with controllers, views and models in the same manner as a regular Rails app. Read … Read more

What is the purpose of config.assets.precompile?

Most assets are automatically included in asset precompilation. According to the RoR Guide on the Asset Pipeline: The default matcher for compiling files includes application.js, application.css and all files that do not end in js or css: [ /\w+\.(?!js|css).+/, /application.(css|js)$/ ] You would use config.assets.precompile if you have additional assets to include: config.assets.precompile += [‘admin.js’, … Read more

Add association (

This should work in Rails 3.2 and Rails 4: post.association(:tags).add_to_target(Tag.first) See this gist: https://gist.github.com/betesh/dd97a331f67736d8b83a Note that saving the parent saves the child and that child.parent_id is NOT set until you save it. EDIT 12/6/2015: For a polymorphic record: post.association(:tags).send(:build_through_record, Tag.first) # Tested in Rails 4.2.5

How to write controller tests when you override devise registration controller?

The problem is that Devise is unable to map routes from the test back to the original controller. That means that while your app actually works fine if you open it in the browser, your controller tests will still fail. The solution is to add the devise mapping to the request before each test like … Read more