Losing an Attribute When Saving Through an Association W/ Scope (Rails 4.0.0)

Rails 4 - Can't update model attribute

Not sure if that's what is causing the issue, but it might. If any method executed as before_save returns false, the whole transaction is aborted.

Your method:

def set_availability
self.is_available = false unless self.status.available?
end

will return false or nil. First case will cancel transaction. Change this method to:

def set_availability
self.is_available = false unless self.status.available?
true
end

Rails attribute value returned in hexadecimal

From https://github.com/leikind/wice_grid#queries-with-join-tables:

Please note that the blockless definition of the column only works with columns from the main table and it won’t work with columns with :model

<%= grid(@questions, show_filters: :false) do |g|
g.column name: 'ID', attribute: 'id', filter: false
g.column name: 'Question', model:'Question', attribute: 'question'
g.column name: 'Keyword', model:'Keyword', attribute: 'keyword' do |question|
question.keyword.keyword
end
end %>

Rails 4.2 Scope queries IS NULL instead of IS NOT NULL

scope: where.not(producer{id: nil} shouldn't work at all. Instead:

# if you need to filter by the attribute of the current model
scope :with_producer, -> { where.not(producer_id: nil) }

# if you need to filter by the attribute of the associated model
scope :with_named_producer, -> { joins(:producer).where.not(producers: { name: nil }) }

Why am I getting a segmentation fault?

You are passing an array a[] in. it must be large enough that the values hi and low are in range.

For example, if you pass an array of size 1 in, and low = 0. hi = 2, then mid = 1 which will be out of range (an array of size 1 can only have a[0] dereferenced, a[1] will be out of range).



Related Topics



Leave a reply



Submit