Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

categories are retrieved based on site_id #559

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

meltingmelon
Copy link
Contributor

Updated index code to now show categories based on site_id.

@@ -12,11 +12,17 @@ def subcategories
end

def index
categories = Category.order(:name)
# categories = Category.order(:name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove if no longer necessary.

categories = if params[:site_id]
Site.find(params[:site_id]).categories
else
Site.find(0).categories #sfsg
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sfsg is not necessarily site_id 0 - a safer way would be using find_by(site_code: 'sfsg').

else
Site.find(0).categories #sfsg
end

top_level = ActiveRecord::Type::Boolean.new.cast(params[:top_level])
categories = categories.where(top_level: top_level) unless top_level.nil?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we preserve the previous commented-out behavior by ordering by name after filtering by site?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants