Last active
December 14, 2015 18:14
-
-
Save beck03076/041a0fb70fb794185183 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
def process_available_days(p) | |
[0,1,0,1,0,1,0] | |
end | |
def prepare_params(p) | |
p[:available_days] = process_available_days(p[:available_days]) | |
p.except(:branches_deals) | |
end | |
def create | |
deals_parameters = prepare_params(deal_params) | |
@deal = Deal.new(deals_parameters) | |
if @deal.save | |
render json: @deal, status: :created, location: @deal | |
else | |
render json: @deal.errors, status: :unprocessable_entity | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment