Llista d'entrades
0
<p>During the upgrading process to Rails 3.2, Devise gem was also upgraded and due to that it raises the following warnings when server starts. I'll also show you the links to remove those annoying warnings.</p>
<pre><code>[DEVISE] Devise.case_insensitive_keys is false which is no longer supported. If you want to continue running
on this mode, please ensure you are not using validatable (you can copy the validations directly to your
model) and set case_insensitive_keys to an empty array.
</code></pre>
<p>Solution: <a href="https://github.com/plataformatec/devise/issues/1607">https://gi...
0
<p>As you may know, Rails 3.2.1 has been released with important improvements of performace. Specially in development environment thanks to <a href="https://github.com/rails/journey">Journey engine</a>.</p>
<p>I have recently faced the task to upgrade some projects to Rails 3.2.1 and I would like to show how I did it. It is easy to proceed.
The main thing I did was change Gemfile as follows:</p>
<pre><code>gem 'rails', '3.2.1'
group :assets do
gem 'sass-rails', " ~> 3.2.3"
gem 'coffee-rails', "~> 3.2.1"
gem 'uglifier', '>= 1.0.3'
end
</code></pre>
<p>Once changed ...
0
<p>I've recently faced the problem to generate PDF files in Rails 3.1. In many projects done with a minor version of Rails we used <a href="https://github.com/mileszs/wicked_pdf">wicked_pdf</a> gem (that use wkhtml2pdf binary to convert html to pdf, as name says) because it make the task easier. It's just render a valid html document but in pdf extension. (More information in their github repository).</p>
<p>Asset Pipeline in Rails 3.1 make stylesheets and images unreachable for wicked_pdf.</p>
<p>The fact of using Asset Pipeline in Rails 3.1 makes me change the way to include CSS and Ima...
0
<p>As I do not have XCode installed in my MacBook (because I use <a href="https://github.com/kennethreitz/osx-gcc-installer">this wonderful solution</a>), I recently ran into a problem with rb-fsevent gem installation.</p>
<p>This gem compiles using some environment stuff that XCode provides, which I didn't have.</p>
<p>So a solution for using this gem is to switch to the following branch on <em>ttilley</em> repo:</p>
<pre><code>
gem 'rb-fsevent', :git => 'git://github.com/ttilley/rb-fsevent.git', :branch => 'pre-compiled-gem-one-off'
</code></pre>
<p>And it works!</p>
<p>From an <a h...
0
<p>I just faced the problem of having to use firefox 7.0.1 in ubuntu 10.04. Not easy at all! By default it comes with the old 3.6 version. You can install the ubuntu mozilla stable ppa and get a newer version from there, but it's currently providing firefox 9.0.1 and selenium does not support it yet.</p>
<p>After trying to install a lower version from the ppa, pinning packages and trying to install the download package manually, the only working way I get was to download the source code and execute it directly.</p>
<p>More consice instructions can be found here:</p>
<pre><code>http://ask...
0
<p>Running selenium specs sometimes it might happen that the test suite is green in our computer, but in the integration server (I've also experienced this issue on Travis) it randomly fails with Capybara ElementNotFound errors or similar, for example:</p>
<pre><code> Failure/Error: text = page.find("##{id} input").value
Capybara::ElementNotFound:
Unable to find css "#best_in_place_user_1210_address input"
</code></pre>
<p>It has been a hard issue to track down, because the real error is a timeout error. It happens that, when executing javascript tests, capybara waits some time before...
0
<p>Within the rspec context we already have access to a special method "helper" wich we can use like this:</p>
<pre><code>it "should show the price" do
res = helper.number_to_currency 56
res.should == "56,00 €"
end
</code></pre>
<p>Well, only in the "request" type specs of course. The problem is that this special 'helper' method is not available to our files under the "spec/support" folder. If we want to make use of it from there we have to run our own solution. This is an easy one: Add a new support file with this content:</p>
<pre><code>
def helper
Helper.instance
end
class Help...
0
<p>In staging environments of our websites we usually want to make everything private, but then external calls to our app, as for example paypal IPN calls, won't be able to reach us.</p>
<p>The solution is a simple nginx configuration:</p>
<pre><code>
server {
listen 80;
server_name staging.myapp.com;
root /my_app_path/current/public;
location / {
auth_basic "Restricted";
auth_basic_user_file basic_auths/pwd_file;
passenger_enabled on;
rails_env staging;
}
location /paypal_ipn {
auth_basic off;
passenger_enabled on;
rails...
0
<p>We know each database handles boolean values on its own way. Fortunatelly enough ActiveRecord provides an abstraction layer that handles this for us, but sometimes we want to known in a POST action if the given parameters are true or not before actually save the model.</p>
<p>This is a simple method hidding in ActiveRecord internals to do that:</p>
<pre><code>ActiveRecord::ConnectionAdapters::Column.value_to_boolean(value)
</code></pre>
<p>This is useful for example if we want to make a virtual boolean attribute, defining this in the model:</p>
<pre><code>def bool_attr=(value)
@boo...
0
<p>The thing what to do if we can set an expectation for a certain object and get control over what it return on two consecutive calls?</p>
<p>Well, we can easily do something like:</p>
<pre><code>@object.should_receive(:method_name).twice.and_return([1, 2])
</code></pre>
<p>Then the first call to <code>@object.method_name</code> will return 1 and the second one 2.</p>
<p>But things can get more complicated if we want, for instance, raise and error on the first call and return '43' on the second one. This is a little more tricky to do, but we can acomplish it with:</p>
<pre><code>@obje...