diff --git a/app/controllers/admin/conference_controller.rb b/app/controllers/admin/conference_controller.rb index 89347905..b3b912cc 100644 --- a/app/controllers/admin/conference_controller.rb +++ b/app/controllers/admin/conference_controller.rb @@ -35,7 +35,7 @@ class Admin::ConferenceController < ApplicationController else redirect_to(edit_admin_conference_path(id: short_title), alert: 'Updating conference failed. ' \ - "#{@conference.errors.full_messages.join('. ')}.") + "#{@conference.errors.full_messages.join('. ')}.") end end diff --git a/app/controllers/admin/organizations_controller.rb b/app/controllers/admin/organizations_controller.rb index 66de3420..9ed2eca5 100644 --- a/app/controllers/admin/organizations_controller.rb +++ b/app/controllers/admin/organizations_controller.rb @@ -13,7 +13,7 @@ class Admin::OrganizationsController < ApplicationController def create @organization = Organization.new(params[:organization]) flash[:notice] = 'Organization was successfully created.' if @organization.save - respond_with @organization, :location => admin_organizations_path + respond_with @organization, location: admin_organizations_path end def show @@ -27,7 +27,7 @@ class Admin::OrganizationsController < ApplicationController def update @organization = Organization.find(params[:id]) flash[:notice] = 'Organization was successfully updated' if @organization.update_attributes(params[:organization]) - respond_with @organization, :location => admin_organizations_path + respond_with @organization, location: admin_organizations_path end def delete @@ -37,7 +37,7 @@ class Admin::OrganizationsController < ApplicationController def destroy @organization = Organization.find(params[:id]) @organization.destroy - redirect_to admin_organizations_path, :notice => "Organization got deleted" + redirect_to admin_organizations_path, notice: 'Organization got deleted' - end + end end diff --git a/app/controllers/admin/sponsorship_levels_controller.rb b/app/controllers/admin/sponsorship_levels_controller.rb index 947a023c..b09dcaff 100644 --- a/app/controllers/admin/sponsorship_levels_controller.rb +++ b/app/controllers/admin/sponsorship_levels_controller.rb @@ -6,11 +6,14 @@ class Admin::SponsorshipLevelsController < ApplicationController end def update - begin - @conference.update_attributes!(params[:conference]) - redirect_to(admin_conference_sponsorship_levels_path(:conference_id => @conference.short_title), :notice => 'Sponsorship levels were successfully updated.') - rescue Exception => e - redirect_to(admin_conference_sponsorship_levels_path(:conference_id => @conference.short_title), :alert => "Sponsorship levels update failed: #{e.message}") + if @conference.update_attributes!(params[:conference]) + redirect_to(admin_conference_sponsorship_levels_path( + conference_id: @conference.short_title), + notice: 'Sponsorship levels were successfully updated.') + else + redirect_to(admin_conference_sponsorship_levels_path( + conference_id: @conference.short_title), + alert: 'Sponsorship levels update failed') end end end diff --git a/app/controllers/admin/sponsorships_controller.rb b/app/controllers/admin/sponsorships_controller.rb index 9ebc38f9..0baeea93 100644 --- a/app/controllers/admin/sponsorships_controller.rb +++ b/app/controllers/admin/sponsorships_controller.rb @@ -8,10 +8,12 @@ class Admin::SponsorshipsController < ApplicationController params[:sponsorship_registration][:conference_id] = @conference.id sponsorship = SponsorshipRegistration.new(params[:sponsorship_registration]) if sponsorship.save - redirect_to(admin_conference_sponsorships_path(:conference_id => @conference.short_title), :notice => "Sponsorship added") + redirect_to(admin_conference_sponsorships_path( + conference_id: @conference.short_title), notice: 'Sponsorship added') else - redirect_to(admin_conference_sponsorships_path(:conference_id => @conference.short_title), - :alert => "Sponsorship creation failed.#{sponsorship.errors.full_messages.join('. ')}") + redirect_to(admin_conference_sponsorships_path(conference_id: @conference.short_title), + alert: 'Sponsorship creation failed.' \ + "#{sponsorship.errors.full_messages.join('. ')}") end end end diff --git a/app/models/conference.rb b/app/models/conference.rb index 07a61f7d..f2791803 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -45,7 +45,7 @@ class Conference < ActiveRecord::Base accepts_nested_attributes_for :venue accepts_nested_attributes_for :dietary_choices, :allow_destroy => true accepts_nested_attributes_for :supporter_levels, :allow_destroy => true - accepts_nested_attributes_for :sponsorship_levels, :allow_destroy => true + accepts_nested_attributes_for :sponsorship_levels, allow_destroy: true accepts_nested_attributes_for :event_types, :allow_destroy => true accepts_nested_attributes_for :email_settings accepts_nested_attributes_for :questions, :allow_destroy => true diff --git a/app/models/organization.rb b/app/models/organization.rb index 28709e4d..0d0407a5 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -2,15 +2,13 @@ class Organization < ActiveRecord::Base attr_accessible :title, :photo, :email_id, :description, :website_url has_many :sponsorship_registrations, dependent: :destroy has_attached_file :photo, - :styles => {:thumb => "100x100>", :large => "300x300>" } + styles: { thumb: '100x100>', large: '300x300>' } validates_attachment_content_type :photo, - :content_type => [/jpg/, /jpeg/, /png/, /gif/], - :size => { :in => 0..500.kilobytes } + content_type: [/jpg/, /jpeg/, /png/, /gif/], + size: { :in => 0..500.kilobytes } validates_presence_of :title, :email_id, :website_url validates_uniqueness_of :email_id - - end diff --git a/app/models/sponsorship_registration.rb b/app/models/sponsorship_registration.rb index 8da8a5e0..49107a3d 100644 --- a/app/models/sponsorship_registration.rb +++ b/app/models/sponsorship_registration.rb @@ -1,5 +1,5 @@ class SponsorshipRegistration < ActiveRecord::Base - attr_accessible :name, :email_id, :contact_no, :amount_donated, :method_of_donation, + attr_accessible :name, :email_id, :contact_no, :amount_donated, :method_of_donation, :sponsorship_level_id, :conference_id, :organization_id belongs_to :organization belongs_to :sponsorship_level diff --git a/db/migrate/20140524122022_create_sponsorship_registrations.rb b/db/migrate/20140524122022_create_sponsorship_registrations.rb index 789df5c1..4441f577 100644 --- a/db/migrate/20140524122022_create_sponsorship_registrations.rb +++ b/db/migrate/20140524122022_create_sponsorship_registrations.rb @@ -1,11 +1,11 @@ class CreateSponsorshipRegistrations < ActiveRecord::Migration def change create_table :sponsorship_registrations do |t| - t.string :name - t.string :email_id - t.string :contact_no - t.float :amount_donated - t.string :method_of_donation + t.string :name + t.string :email_id + t.string :contact_no + t.float :amount_donated + t.string :method_of_donation t.belongs_to :organization t.belongs_to :sponsorship_level t.belongs_to :conference diff --git a/db/migrate/20140524122046_create_organizations.rb b/db/migrate/20140524122046_create_organizations.rb index 710acd66..2d8eb65e 100644 --- a/db/migrate/20140524122046_create_organizations.rb +++ b/db/migrate/20140524122046_create_organizations.rb @@ -1,13 +1,13 @@ class CreateOrganizations < ActiveRecord::Migration def change create_table :organizations do |t| - t.string :title - t.string :email_id - t.text :description - t.string :photo_file_name - t.string :photo_content_type - t.integer :photo_file_size - t.datetime :photo_updated_at + t.string :title + t.string :email_id + t.text :description + t.string :photo_file_name + t.string :photo_content_type + t.integer :photo_file_size + t.datetime :photo_updated_at t.timestamps end end diff --git a/spec/factories/conferences.rb b/spec/factories/conferences.rb index 3acd4103..09fd1b4a 100644 --- a/spec/factories/conferences.rb +++ b/spec/factories/conferences.rb @@ -11,7 +11,7 @@ FactoryGirl.define do end_date Date.tomorrow factory :conference_with_sponsorship_level do after(:build) do |conference| - conference.sponsorship_levels << build(:sponsorship_level, conference: conference) + conference.sponsorship_levels << build(:sponsorship_level, conference: conference) end end end diff --git a/spec/factories/sponsorship_registrations.rb b/spec/factories/sponsorship_registrations.rb index b613cc5b..fde0caa2 100644 --- a/spec/factories/sponsorship_registrations.rb +++ b/spec/factories/sponsorship_registrations.rb @@ -11,9 +11,9 @@ FactoryGirl.define do sponsorship_level organization after(:build) do |sponsorship_registration| - sponsorship_registration.sponsorship_level = - build(:sponsorship_level, - conference: sponsorship_registration.conference) + sponsorship_registration.sponsorship_level = + build(:sponsorship_level, + conference: sponsorship_registration.conference) end end end