Skip to content
This repository has been archived by the owner on Jul 19, 2021. It is now read-only.

Commit

Permalink
Merge pull request #170 from a-barbieri/master
Browse files Browse the repository at this point in the history
Fixes and new release
  • Loading branch information
a-barbieri authored Feb 26, 2018
2 parents dd37f34 + e6a4d81 commit afde99d
Show file tree
Hide file tree
Showing 8 changed files with 2,874 additions and 4,145 deletions.
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
binda (0.1.6.alpha.5)
binda (0.1.6)
aasm (>= 4.11, < 4.13)
ancestry (>= 2.1, < 3.1)
bourbon (= 4.3.4)
Expand Down Expand Up @@ -291,7 +291,7 @@ GEM
thor (0.20.0)
thread_safe (0.3.6)
tilt (2.0.8)
tinymce-rails (4.7.6)
tinymce-rails (4.7.7)
railties (>= 3.1.1)
tinymce-rails-langs (4.20180103)
tinymce-rails (~> 4.1, >= 4.1.10)
Expand Down
6 changes: 6 additions & 0 deletions app/controllers/binda/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class ApplicationController < ActionController::Base
protect_from_forgery with: :exception

before_action :authenticate_user!
before_action :set_locale

# _ indicates that we are not using the argument in the method
def after_sign_in_path_for(_)
Expand All @@ -15,5 +16,10 @@ def after_sign_out_path_for(_)
root_path
end

# Avoid inheriting locale from application on which Binda is mounted
def set_locale
I18n.locale = I18n.default_locale
end

end
end
19 changes: 10 additions & 9 deletions app/models/binda/component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ def self.sort_limit
1000
end

# Create field instances for the current component
def create_field_instances
instance_field_settings = FieldSetting
.includes(field_group: [ :structure ])
.where(binda_structures: { id: self.structure.id })
instance_field_settings.each do |field_setting|
field_setting.create_field_instance_for(self)
end
end

private

def set_default_position
Expand All @@ -60,14 +70,5 @@ def set_default_position
.each{|component| component.increment(:position).save!}
end

# Create field instances for the current component
def create_field_instances
instance_field_settings = FieldSetting
.includes(field_group: [ :structure ])
.where(binda_structures: { id: self.structure.id })
instance_field_settings.each do |field_setting|
field_setting.create_field_instance_for(self)
end
end
end
end
2 changes: 1 addition & 1 deletion lib/binda/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Binda
VERSION = '0.1.6.alpha.5'.freeze
VERSION = '0.1.6'.freeze
end
10 changes: 10 additions & 0 deletions lib/tasks/create_missing_field_instances_task.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace :binda do
desc "Create missing field instances for each component and board"
task :create_missing_field_instances => :environment do
Binda::Component.all.each do |component|
puts "checking component ##{component.id}"
component.create_field_instances
puts "component ##{component.id} checked"
end
end
end
Loading

0 comments on commit afde99d

Please sign in to comment.