Sign in through GitHub

JPN's Profile

GitHub User: jonathanng

Site: teamjotty.com

Comments by JPN

Avatar

Turbolinks is like an electric car...it's so smooth, you don't even know it's working. And from a UI perspective, that can be bad.

The git page in one of it's examples has this:

javascript
document.addEventListener("page:fetch", startSpinner);
document.addEventListener("page:receive", stopSpinner);

I'm not sure if I like this. It's like adding a fake engine noise that is louder than a regular engine.

I'm curious if anyone has any good solutions.

Avatar

Not sure if this is the most elegant, but this works if you want permission.rb working with Carrierwave.

in def initialize(user)
allow_nested_param :post, :photos_attributes, [:image]
added method in permission.rb
def allow_nested_param(resources, attribute, nested_attributes)
  @allowed_params ||= {}
  Array(resources).each do |resource|
    @allowed_params[resource.to_s] ||= []
    @allowed_params[resource.to_s] += [{ attribute.to_s => Array(nested_attributes).map(&:to_s)}]
  end
end

References:
strong parameter example for hashes with integer keys
strong_parameters#nested-parameters