...Otherwise add database_cleaner to your *Gemfile`. This lets you say this from the Rails console: DatabaseCleaner.strategy = :truncation DatabaseCleaner.clean You can package this into a nice little Rake task by...

...can e.g. clean the test database by saying on the shell: rake db:clean RAILS_ENV=test If you are using the parallel_tests gem, the task is aware and...

makandra dev
github.com

...example to confirm your output in tests), you can use roo. To easily dump Rails records to XLSX, there is also axlsx_rails (haven't tried it yet). xlsx generation...

If possible, make the autoloaded class static by moving it out of Rails' load path...

...it's usually not part of the Gem's API). Unless you're using Rails 4 (which brings String#indent in ActiveSupport), you'll be best of defining it yourself...

...data in columns. This is helpful for e.g. comparing attributes of a set of Rails records. def tp(objects, *method_names) terminal_width = `tput cols`.to_i cols = objects.count...

...disabled, that all classes are already loaded when browser interaction takes place what makes rails able to find the class even without the namespace...

...last_synchronized_at: nil, } } ) def validate_analytic_stats_against_json_schema @schema ||= File.read(File.join(Rails.root, 'app', 'models', 'project', "analytic_stats_schema_v#{analytics_stats_version}.json")) analytic_stats_errors = JSON...

...or by setting self.primary_key = "id" in your class definition. Related, but different issue: Rails 2 does not find an association when it is named with a string instead of...

blog.jayfields.com

...these styles, and system will fail when passing it invalid arguments: system 'bundle exec rails server', '-p 3000' # fails and returns nil This is equivalent to running a command called...

...bundle exec rails" (including spaces in its filename). There is usually no such command anywhere on the $PATH. Note that you should prefer the 2nd approach (list of arguments instead...

...cassette for the request that fails Copy the request with all parameters Open a rails console, assign the request to a variable and unescape it: my_project> var = "%5B%7B...

...LIKE only takes a fraction of a second. This means when optimizing a typical Rails action, you should probably look further than the database. A view can easily take many...

...a model Signature with name: string, signature: text, you can use it with regular rails form like this: - form_for @signature, :html => { :class => 'signature_form' } do |form| %dl %dt = form.label...

In Ruby on Rails, all objects have a useful blank? method. It returns true for nil but also for empty strings or empty arrays. There is also a universal method...

...When dealing with geo data, you'd often use acts_as_geocodable for your Rails applications. There you can just use your model's upgraded find to achieve the same...

jqueryui.com

...into position[]=13&position[]=15, which neatly resolves to params[:position] == [13, 15] in Rails. Broken placeholder height When a dragged row does not have a set height but rather...

...it really hard to make this work reliably. Also see Dynamically uploading files to Rails with jQuery File Upload...

github.com

...Minidusen, which extracts those parts from Dusen. Minidusen is compatible with MySQL, PostgreSQL and Rails 3.2, 4.2 and 5.0. If you are looking for a full text indexing solution, we...

...to invalidate Cloudfront cached assets, and Cloudfront will ignore the usual ?123456 timestamps that Rails uses by default. So to make sure Cloudfront will not server outdated assets, you have...

...to remember the password, give a form an autocomplete attribute with the value off: ... Rails example form_for @model, :html => { :autocomplete => "off" } do |form...

rubyforge.org

Under certain circumstances gettext_i18n_rails will hit a near-infinite loop. This occured in Rails 2.3.5 with Haml 3.0.18 and fast_gettext 0.5.10. gettext_i18n_rails's Haml-Parser...

stackoverflow.blog

...opensource.zalando.com/restful-api-guidelines https://www.merixstudio.com/blog/best-practices-rest-api-development/ https://www.oreilly.com/library/view/rest-api-design/9781449317904/ More topics in our deck: Rails: Rest API post-mortem analysis InfoQ: How to Design a Good API & Why it Matters

...iconfont-plugin-webpack that automate the font building. If you're still using the Rails asset pipeline, try the half-automatic approach. Webpacker Rails: How to integrate the plugin

This note describes how to kick a user out of a Rails application after she hasn't requested an action for a while. Note that this is different from deleting...

...node version that is older than mine. Every time I wanted to run my rails dev server I was asked to check my yarn integrity: error Integrity check failed

+ "systemParams": "linux-x64-64", "modulesFolders": [ "node_modules" ], - "flags": [], + "flags": [ + "checkFiles" + ], "linkedModules": [], "topLevelPatterns": [ "@rails/webpacker@4.x", There were also changes in node_modules/node-sass/vendor/linux-x64-64/binding.node. After I switched to the "correct...