Created
September 2, 2013 13:55
-
-
Save pschyska/6413138 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Backend::Settings::TiersController < BackendController | |
before_filter :authorize_admin | |
def index | |
@tiers = current_company.tiers.order('sort ASC') | |
end | |
def update | |
@tier = current_company.tiers.find(params[:id]) | |
old_sort = @tier.sort | |
@tier.update_attributes(params[:tier]) | |
if @tier.sort_changed? | |
# search for another tier in this company with the new sort | |
# if it exists, swap sort values | |
if other = Tier.where(sort: @tier.sort).first | |
# FIXME: we have to skip validations here ... | |
other.update_attribute(:sort, old_sort) | |
end | |
end | |
@tier.save! | |
p Tier.all | |
redirect_to action: :index | |
end | |
def move_up | |
end | |
def move_down | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment