Skip to content

Conversation

@meltingmelon
Copy link
Contributor

Updated index code to now show categories based on site_id.


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').

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