...So if your project doesn't support Rails-XSS just remove all .html_safe calls.
...Ruby version only to make the release, then switch back. You will have to call the rake release command without bundle exec...
puts "Hello" end end While you can say create a block to call that method (using ampersand and colon) on Ruby 1.8, ... 1.8.7 > Foo.new.tap(&:test) Hello => # ... you cannot...
...do that on Ruby 1.9 or 2.0: 1.9.3 > Foo.new.tap(&:test) NoMethodError: private method `test' called for # ^ 2.0.0 > Foo.new.tap(&:test) NoMethodError: private method `test' called for #Foo:0x000000027bc738
...the conversation, use /alertson KEYWORD Note that multiple keywords must be defined with one call, as each call will overwrite previous keywords. Separate them by spaces: /alertson KEYWORD1 KEYWORD2
...I use this handy shell script to set one site as the current one. Call it just like this: apache-site makandra-com Note that it disables all other sites...
...Furthermore it will also enable the default site if that was available. When you call apache-site with no arguments, it will list all available sites. This script is part...
If a SOAP API expects you to call a remote method with arguments of complex types, Savon lets you manually set the xsi:type attribute like this: client.call(:rpc_method...
puts body.body # html of response body Instead of Rails.application you can also call any Rack application...
undefined method `log' for # Your affected code might look similar to this call below and will work after the upgrade again. errors = page.driver.browser.manage.logs.get(:browser...
...block. You can use Object#method to obtain a method reference that responds to #call: foo_plus = "foo".method(:+) foo_plus.call("bar") # => "foobar" The method reference also understands #to_proc so...
...arrays, true story.) Adding values Use the array_cat function, or the || operator. These calls will add the values "cats" and "mice" to users.topics: UPDATE users SET topics = array_cat...
...defined via the resource method. When you put resource 'user' into config/routes.rb, you can call users_path and get the path to the index action in the UsersController: /users.
...states, Rails creates a special _index_path for this scenario. Thus, you can simply call: sheep_index_path
...with_advisory_lock gem but you could easily use something else. class SidekiqMailersThrottle def call(worker, job_options, queue) if queue == 'mailers' ApplicationRecord.with_advisory_lock('mailers-throttle') do yield
...possible security vulnerabilities caused by this. If you want to find out if the call was successful you can ask $?.success?. system – when you want to know how it went...
...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...
...scope, but what if you need to pluck Global IDs? While you could just call map(&:to_global_id) on your scope, this approach would instantiate each record just to...
...This can easily be achieved through a Sidekiq middleware as follows. class RailsLoggerSidekiqServerMiddleware def call(worker, job_options, queue) tags = [worker.class.name, worker.jid] Rails.logger.tagged(*tags) { yield } end end Sidekiq.configure_server do...
In order to prove multiple values from a single object, Ruby calls #to_a on the object: o = String.new('O') def o.to_a [1,2,3]
...a, b, c = o # Implicit call to #to_a here a # => 1 b # => 2 c # => 3 Hence, if you want your class to support multiple assignment, make sure to define...
Ruby 1.9 brings a shorter way to define lambdas using the -> operator: twice = -> (x) { 2 * x } twice.call(5) # => 10
...form.build_nested_records(:actors, :minimum: 4, name: 'Foo', active: true) If you want to call a different method rather than build, you can pass a block: form.build_nested_records(:actors...
...uploader dynamically generates the filename (e.g. by incorporating a user's name), you must call model.save! after recreating versions. uploader.recreate_versions! does not update the model with the stored filename...
Call geordi clean from a project root to remove unused and unnecessary files inside it. This script is part of our geordi gem on github. In Geordi > 1.2 you can...
...call geordi clean...
If you have multiple monitors and want to share a given screen with your call partner, drag the caller window to the desired monitor, then start sharing.
This tool is used on our application servers (and called when deploying) but it also works locally. Just call dumple development from your project directory to dump your database.
To call a class method (or static method) from an instance method: class.method() To call a class method from a class method:
...with the following line: # application_controller.rb rescue_from ActiveRecord::RecordNotFound, :with => :render_404 This will call the method render_404 whenever a RecordNotFound error occurs (you could pass a lambda instead...