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 #194 from a-barbieri/master
Browse files Browse the repository at this point in the history
Update Guidelines and FIXES
  • Loading branch information
a-barbieri authored May 18, 2018
2 parents 3c53385 + 5fd9c33 commit 9809682
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 11 deletions.
36 changes: 29 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ A modular CMS for Ruby on Rails 5.1.
[![Gem Version](https://badge.fury.io/rb/binda.svg)](https://badge.fury.io/rb/binda)
[![Code Climate](https://codeclimate.com/github/lacolonia/binda/badges/gpa.svg)](https://codeclimate.com/github/lacolonia/binda)
[![Test Coverage](https://api.codeclimate.com/v1/badges/5dc62774a6b8b63aa72b/test_coverage)](https://codeclimate.com/github/lacolonia/binda/test_coverage)
[![Dependency Status](https://gemnasium.com/badges/github.com/lacolonia/binda.svg)](https://gemnasium.com/github.com/lacolonia/binda)
[![Inline docs](http://inch-ci.org/github/lacolonia/binda.svg?branch=master)](http://inch-ci.org/github/lacolonia/binda)

> This documentation has been written for the [Official Documentation](http://www.rubydoc.info/gems/binda), not the Github README.
Expand All @@ -16,7 +15,7 @@ A modular CMS for Ruby on Rails 5.1.

# Quick Start

**Binda** is a headless CMS with an intuitive out-of-the-box interface which makes very easy to create your application infrastructure.
**Binda** is a headless CMS with an intuitive out-of-the-box interface which makes very easy creating application infrastructures.

The core element is the _structure_ element which is the finger print of any _component_ instance. Every _structure_ can have one or more _field-groups_ which can be populated with several _field-settings_. _Field-groups_ and _field-settings_ represent _components_ features, such as galleries, textareas, dates, repeaters and so on.

Expand Down Expand Up @@ -60,7 +59,7 @@ bundle install

Before completing the installation you need to setup the database. If you are going to use Postgres set it up now.

To complete binda installation run the installer from terminal. Binda will take you through a bit of configuration where you will setup the first user and some basic details.
To complete binda installation run the installer from terminal. Binda will take you through a short configuration process where you will setup the first user and some basic details.

```bash
rails generate binda:install
Expand Down Expand Up @@ -902,18 +901,41 @@ Some specs are run against the database. If you haven't installed Binda on the d
RAILS_ENV=test rails db:migrate
```

The above command might generate an error. This is probably because you have previously installed Binda and the generator finds migration both in `binda/db/migrate` and `binda/spec/dummy/db/migrate`. To solve the issue, remove the `spec/dummy/db/migrate` folder and run the previous command again. Here below the oneliner (be aware that this destroy both development and test databases of the dummy app):
The above command might generate an error. This is probably because you have previously installed Binda and the generator finds migration both in `binda/db/migrate` and `binda/spec/dummy/db/migrate`. To solve the issue, remove the `spec/dummy/db/migrate` folder and run the previous command again.

```bash
cd spec/dummy && rm -rf db/migrate && rails db:drop && rails db:create && RAILS_ENV=test rails db:migrate
cd spec/dummy
rm -rf db/migrate
rails db:drop
rails db:create
RAILS_ENV=test rails db:migrate
cd ../..
```

In case you are creating new migrations or modifing the default one:
Here the oneliner:

```bash
cd spec/dummy && rm -r db/schema.rb && rails db:drop && rails db:create && RAILS_ENV=test rails db:migrate
cd spec/dummy && rm -rf db/migrate && rails db:drop && rails db:create && RAILS_ENV=test rails db:migrate && cd ../..
```

If Binda migration have been updated then your `schema.rb` is outdated and will generate false failing tests. In this case you need to run following command to refresh your database configuration:

```bash
cd spec/dummy
rm -r db/schema.rb
rails db:drop
rails db:create
rails generate binda:install
rm -rf db/migrate
rm -rf config/initializers/devise_backup_*.rb
cd ../..
```

Here the oneliner:

```bash
cd spec/dummy && rm -r db/schema.rb && rails db:drop && rails db:create && rails generate binda:install && rm -rf db/migrate && rm -rf config/initializers/devise_backup_*.rb && cd ../..
```

If in the future you need to clean your dummy app code, simply run:

Expand Down
2 changes: 1 addition & 1 deletion app/models/binda/field_setting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ def is_rejected( attributes )
end

after_save do
self.class.reset_field_settings_array
add_choice_if_allow_null_is_false
create_field_instances
end

after_create do
self.class.reset_field_settings_array
convert_allow_null__nil_to_false
set_default_position
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ def get_radio_choice(field_slug)
return { label: obj.choices.first.label, value: obj.choices.first.value }
end

# Get the select choices
# Get the select choice
#
# @param field_slug [string] The slug of the field setting
# @return [hash] A hash of containing the label and value of the selected choice. `{ label: 'the label', 'value': 'the value'}`
# @return [hash] A hash of containing the label and value of the selected choice. `{ label: 'the label', value: 'the value'}`
def get_selection_choice(field_slug)
field_setting = FieldSetting.find_by(slug:field_slug)
obj = self.selections.find{ |t| t.field_setting_id == field_setting.id }
Expand All @@ -31,7 +31,7 @@ def get_selection_choice(field_slug)
# Get the select choices
#
# @param field_slug [string] The slug of the field setting
# @return [array] An array of hashes of containing label and value of the selected choices. `{ label: 'the label', 'value': 'the value'}`
# @return [array] An array of hashes of containing label and value of the selected choices. `{ label: 'the label', value: 'the value'}`
def get_selection_choices(field_slug)
field_setting = FieldSetting.find_by(slug:field_slug)
obj = self.selections.find{ |t| t.field_setting_id == field_setting.id }
Expand Down
1 change: 1 addition & 0 deletions spec/factories/structures.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
create :repeater_setting_with_children_settings, field_group: default_field_group
create :radio_setting_with_choices, field_group: default_field_group
create :selection_setting_with_choices, field_group: default_field_group
create :checkbox_setting_with_choices, field_group: default_field_group
create_list( :article_component, evaluator.components_count, structure: structure)
end
end
Expand Down

0 comments on commit 9809682

Please sign in to comment.