...additional step to keep your cookies valid. Issue Sidekiq::Web is mounted into your Rails application and will use the Rails session cookie for protection from CSRF attacs. While it...
...Sidekiq::Web like this: # config/initializers/sidekiq.rb require 'sidekiq/web' Sidekiq::Web.set :sessions, domain: <domain here, e.g. Rails.configuration.x.cookie_domain...
...images, this slows down development response times. You can fix that by defining a Rails route like this: if Rails.env.development? scope format: true, constraints: { format: /jpg|png|gif/ } do
...presenter may keep them from reinventing the app logics-wheel, but feels like reinventing the Rails-wheel. (Arne) Bad: Duplicate Validations are bound to be problematic. This could have been...
...require to require_relative where I loaded RSpec factories in Cucumber's env.rb (the Rails application root is no longer in the load path by default) replacing the old debugger...
...to your Gemfile. iconv is a part of Ruby that was removed in 2.0. Rails 3 seems to depend on it. All the pain with magic # encoding: utf-8 comments...
...go, all you need to do is prefix every command with zeus. That means rails server becomes zeus server, rails console becomes zeus console, and so on. From the Github...
Zeus preloads your Rails app so that your normal development tasks such as console, server, generate, and specs/tests take less than one second. Requirements: OS X 10.7+ or Linux...
In Ruby on Rails, all the routes of a given application can be found within the config/routes.rb file. You add more and more routes in this file as your project...
...important to find a way to order and maintain your routes. See: Clean your Rails routes: grouping Sometimes the routes.rb grows very fast and each line adds more confusion to...
...it will look like this: >> Socket.gethostname => "happycat" That should work right away for your Rails application. For plain Ruby, you first need to do: require 'socket'
...often is) different from the host that a user is requesting in their current Rails session (request.host). Also keep in mind that hostname might give you the FQDN depending on...
...list like this: ----- Passenger processes ----- PID VMSize Private Name ------------------------------- 671 112.9 MB 95.5 MB Rails: /opt/www/project1/current 707 79.4 MB 60.5 MB Rails: /opt/www/project2/current 1094 88.1 MB 69.3 MB Rails: /opt/www/project3/current...
...MB 62.6 MB Rails: /opt/www/project4/current 1269 72.9 MB 55.6 MB Rails: /opt/www/project5/current
Let's say you need to revert a migration that happened a while back. You'd create a new migration...
You don't need a Rails application to use Sass. Even when you're working on a static site you can generate your CSS through Sass. Install Sass with sudo...
...gitignore to not exclude public/stylesheets/*.css, since stylesheets aren't being generated automatically without Rails (this would bite you after a deploy). Instead exclude .sass-cache, which will be created...
In specs, the session never persists but is always a new object for each request. Data put into the session...
Any 404 error that is caused by something not found in your Rails app will render a nice message using your default layout. Similarly, you may catch and...
...is a MongoDB adapter for Ruby. We've forked it so it works for Rails 2.3.x applications running on Ruby 1.9. [1] makandra/mongomapper is based on the "official" rails2...
...it, add this to your Gemfile: gem 'mongo_mapper', :git => 'git://github.com/makandra/mongomapper.git', :branch => 'rails2' [1] The last version to be compatible with Rails 2 was 0.8.6: While there are...
In Rails 7.1 it has become possible to annotate partials with the locals they expect: # partial _user_name.erb <%# locals: (user:) %> <%= user.name %> # view <%= render 'user_name' %> <%# this raises an ArgumentError %> Unfortunately, when...
...temporarily remove the annotation to see the correct error. Niklas opened an issue in rails, a fix is merged and will arrive in Rails >7.2.2.2 and...
...on how we make our app(s). In the beginning, there was the monolithic Rails app in the standard way with 100+ models and their many corresponding controllers and views...
...one via API. Our newest project is a single “app” made up of several Rails engines. We have found that this strikes a great balance between the (initial) straightforwardness of...
Last week saw a security issue with rails 2.3 that required a fix. While an official patch was provided, the 2.3 branch is no longer maintained. So we forked it...
...but they are not very easily discoverable.) To use our fork, change the gem "rails"... line in your Gemfile to this: gem 'rails', :git => 'https://github.com/makandra/rails.git', :branch...
...port and the username (default root) and password (default msandbox). When working on a Rails project, you need to paste all of that into your config/database.yml. Connecting to a sandbox...
Under certain (unknown) circumstances, Rails will give localized files an invalid content-type in the Response header. For me, after requesting corporate_information and rendering corporate_information.de.html.haml, Rails sent a content...
...topic that offer workarounds, but none solved it for me. The issue occurred with Rails...
When writing Rails migrations to convert a string column to an integer you'd usually say: change_column :table_name, :column_name, :integer However, PostgreSQL will complain: PG::DatatypeMismatch: ERROR...
...led me to the solution: I had to write has_many placeholder.to_sym. When Rails can't find an association, make sure it's defined as symbol Seemingly, that's...
...a bug in Rails...
The ActionMailer in Rails 2 depends on a buggy version of TMail, which sometimes inserts a blank line into the mail header when sending a mail to multiple recipients. This...
...mail through an MTA like Exim, it will fix this for you. Fix for Rails if you don't have an awesome MTA TMail is no longer maintained. The bug...
Ever wondered how Rails talks to itself in a Cucumber feature? In Rails 3 you can do it like this: def rack_env(path) { "rack.input" => {}, "PATH_INFO"=>"#{path}", "REQUEST_METHOD...
end request = rack_env('/users/new') response = Rails.application.call(request) status, headers, body = response puts status # e.g. 200 puts headers.inspect # hash of headers puts body.body # html of response body
See this Railscast. Basically you can simply write views like index.xlsx.erb: ID Name Release Date Price <% @products.each do |product| %> <%= product.id %> <%= product.name %> <%= product.released_on %> <%= product.price %> <% end %> This approach may help us...
...it has always worked: NoMethodError: undefined method `allow_value' for # This is due to Rails 4.1 (specifically, Spring) revealing a weak point of shoulda-matchers -- jonleighton explains why. Solution