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

Use find instead of find by id #1831

Merged
merged 7 commits into from
Jan 24, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Use correct param in controller
There were some custom routes created using the param[:id] but the
Rails routes use the param[:budget_id] by default, so the same
controller could be asked for different param keys.
  • Loading branch information
microweb10 committed Jan 17, 2019
commit 43be16e34fe0773f2f3581686c92f4ead98f276c
2 changes: 1 addition & 1 deletion app/controllers/budgets/executions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def investments_by_heading
end

def load_budget
@budget = Budget.find_by(slug: params[:id]) || Budget.find_by(id: params[:id])
@budget = Budget.find_by(slug: params[:budget_id]) || Budget.find_by(id: params[:budgetid])
end

def investments_by_heading_ordered_alphabetically
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/budgets/results_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ def show
private

def load_budget
@budget = Budget.find_by(slug: params[:id]) || Budget.find_by(id: params[:id]) || Budget.first
@budget = Budget.find_by(slug: params[:budget_id])
@budget ||= Budget.find_by(id: params[:budget_id])
@budget ||= Budget.first
end

def load_heading
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/budgets/stats_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def load_stats
end

def load_budget
@budget = Budget.find_by(slug: params[:id]) || Budget.find_by(id: params[:id])
@budget = Budget.find_by(slug: params[:budget_id]) || Budget.find_by(id: params[:budget_id])
end

end
Expand Down