rafaelfranca on master
Prevent TextHelper#word_wrap fr… Merge pull request #34488 from … (compare)
rafaelfranca on master
Indent guides as rails help com… Homogenize rails help output I… Merge pull request #34085 from … (compare)
rafaelfranca on 5-2-stable
Merge pull request #34106 from … (compare)
Hi everyone, i have a problem with a complex eager loading scenario. I have a data model like this:
class Closure < ApplicationRecord
has_and_belongs_to_many :geo_refs
end
class GeoRef < ApplicationRecord
end
I use to cancancan
gem for filtering both record types by users permissions.
So my current query looks like this:
@closures = Closures.includes(:geo_refs).accessible_by(current_ability, :read)
But that will of course eager load all GeoRef of a closure. Not just the one accessible by the user. I need to apply the accessible_by filter again for the eager loaded association.
@geo_refs = GeoRef.joins(:closures).where('closures.id': @closures).accessible_by(current_ability, :read)
closures.id
?{ 1: [#<GeoRef id:1>, #<GeoRef id:2>], 2: [...] }
@geo_refs = GeoRef.joins(:closures).where('closures.id': @closures).accessible_by(current_ability, :read) \
.select('closures.id AS closure_id, geo_refs.*').index_by(&:closure_id)
type rvm
it should output function, if not you need to reinstall it.
Hi @ScottG489, with HTTP2 you can do stream prioritization.
Never implemented it myself but have a look here (scroll down to the Stream Prio paragraph):
https://www.speedshop.co/2016/01/07/what-http2-means-for-ruby-developers.html
https://discuss.rubyonrails.org/t/what-is-the-story-with-http-2-in-rails/75224/3
Definitely something to learn here
I have this model Person
class Person
generate_public_uid generator: PublicUid::Generators::HexStringSecureRandom.new(32)
has_many :addresses, as: :resource, dependent: :destroy
accepts_nested_attributes_for :addresses, allow_destroy: true, update_only: true,
reject_if: proc { |attrs| attrs[:content].blank? }
end
in my person table, I have this public_id that is automatic generated when a person is created. now the nested attribute in adding addresses is working fine. but the update is not the same as what nested attribute default does. my goal is to update the addresses using public_id
class Address
generate_public_uid generator: PublicUid::Generators::HexStringSecureRandom.new(32)
belongs_to :resource, polymorphic: true
end
this is my address model
I'm using the public id to my primary key. and trying to update nested attribute using the public_id
private
method?" ?
class Testit
def private
puts 'ok, its private then'
private_thing
end
private
def private_thing
puts ' test'
end
end
a = Testit.new
a.private
# ok, its private then
# test
private
messes up the class:
class Plop
def self.private
puts 'yep?'
end
private
def self.plop
private
end
end
yep?
=> :plop
private()
is called on class definition...
catalog.published?
is an instance method; an instance method named private
seems ok (example. 1)
Catalog.status
to get the enum)
nature
enum, Rails creates MyClass.natures
environment
rake task to get the rails environment inside