Flowdock

Notes posted by bsiggelkow

RSS feed
October 9, 2008 - (<= v2.1.0)
12 thanks

Rendering nothing

If your controller action does not explicitly call render, Rails will, by default, attempt to locate and render the template corresponding to the action. It’s not uncommon, for example with Ajax calls, to want to render nothing. This will circumvent the default rendering and prevent errors on missing templates. To render nothing simply do the following:

render :nothing => true

Its important to note that this isn’t the same as returning no HTTP response. In fact, this results in an HTTP response with a status code of 200 OK being sent back with a blank content body. Why does it matter? Well, you can still test your controller by asserting that a :success response was returned.

September 26, 2008 - (v1.2.6 - v2.1.0)
5 thanks

Pass the observed fields value as a parameter in the Ajax request

Use encodeURIComponent with with to pass an encoded value as a parameter (POST or GET) of the AJAX request. For example:

<%= observe_field :company_id,

:url => {:action => ‘facilities’, :only_path => false}, :with => “‘company=’ + encodeURIComponent(value)” %> Also, setting only_path => false for the URL ensures that the full URL (including host and protocol) is used for the AJAX request.

August 21, 2008 - (v2.1.0)
0 thanks

Calling 'last' on a has_many assoication where the order is specified as a symbol raises an error.

Calling ‘last’ on a has_many assoication where the order is specified as a symbol raises an error. If you use :order, the value must be a string and not a symbol. (Prior to 2.1, :order would accept a string).

There is an incomplete Lighthouse ticket for this at http://rails.lighthouseapp.com/projects/8994/tickets/341-calling-last-on-a-has_many-assoication-where-the-order-is-specified-as-a-symbol-raises-an-error#ticket-341-1