Skip to content

Commit

Permalink
fixing hardcoded Settings.find_by_id(1) bug to Settings.first and pla…
Browse files Browse the repository at this point in the history
…cing alerts in flash display
  • Loading branch information
Ramy Mostafa authored and liuhenry committed Jan 18, 2014
1 parent d101a46 commit 6a2f579
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/models/campaign.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def expiration_date_cannot_be_in_the_past
end

def payments_can_be_activated
if self.production_flag && !Settings.find_by_id(1).payments_activated?
if self.production_flag && !Settings.first.payments_activated?
errors.add(:base, "cannot activate payments")
end
end
Expand Down
5 changes: 1 addition & 4 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,10 @@
<%= render 'layouts/social_js' %>
<%= render 'layouts/navbar' %>
<%= render 'theme/views/header' %>
<% flash.to_hash().slice(:success, :info, :notice, :error).each do |key, value| %>
<% flash.to_hash().slice(:success, :info, :notice, :error, :alert).each do |key, value| %>
<% if !value.blank? %><div class="alert alert-<%= key %>"><%= value %></div><% end %>
<% end %>
<div id="main">
<% if alert %>
<p class="admin-alert alert alert-error"><%= alert %></p>
<% end %>
<%= yield %>
</div>
<%= render 'theme/views/footer' %>
Expand Down
4 changes: 2 additions & 2 deletions lib/tasks/sync_payments.rake
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ namespace :ch do
campaign = Campaign.find_by_ct_campaign_id(ENV['CAMPAIGN_ID'])
if campaign
puts "Synching payments for #{campaign.name} (#{ENV['CAMPAIGN_ID']})"
campaign.production_flag ? Crowdtilt.production(Settings.find_by_id(1)) : Crowdtilt.sandbox
campaign.production_flag ? Crowdtilt.production(Settings.first) : Crowdtilt.sandbox
begin
response = Crowdtilt.get("campaigns/#{campaign.ct_campaign_id}/payments?page=1&per_page=100")
rescue => exception
puts exception.message and abort
end
end
ct_payments = response['payments']
pages = response['pagination']['total_pages']

Expand Down

0 comments on commit 6a2f579

Please sign in to comment.