-
Notifications
You must be signed in to change notification settings - Fork 24
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,11 +12,17 @@ def subcategories | |
end | ||
|
||
def index | ||
categories = Category.order(:name) | ||
# categories = Category.order(:name) | ||
# Cast: | ||
# nil and '' -> nil | ||
# '0', 'false', 'False', 'f', etc. -> false | ||
# Almost everything else -> true | ||
categories = if params[:site_id] | ||
Site.find(params[:site_id]).categories | ||
else | ||
Site.find(0).categories #sfsg | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
end | ||
|
||
top_level = ActiveRecord::Type::Boolean.new.cast(params[:top_level]) | ||
categories = categories.where(top_level: top_level) unless top_level.nil? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||
render json: CategoryPresenter.present(categories) | ||
|
There was a problem hiding this comment.
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.