Remove duplicates and bad code habits.

Remove some blank line.

Do not chain bang methods.
This commit is contained in:
James Fleming 2013-07-09 14:19:55 +02:00 committed by Jonne Haß
parent 66a07bd938
commit 9ca9a6f310
6 changed files with 13 additions and 9 deletions

View file

@ -66,7 +66,7 @@ gem 'roxml', '3.1.6'
gem 'ruby-oembed', '0.8.8'
#Rails 4 integration
# Please remove when migrating to Rails 4
gem 'strong_parameters'
@ -97,10 +97,6 @@ gem 'haml', '4.0.3'
gem 'mobile-fu', '1.2.1'
gem 'will_paginate', '3.0.4'
# Strong parameters
gem 'strong_parameters'
### GROUPS ####

View file

@ -50,7 +50,6 @@ class InvitationsController < ApplicationController
end
def create
inviter_params = params.require(:email_inviter).permit(:message, :locale, :emails)
emails = inviter_params[:emails].split(',').map(&:strip).uniq
valid_emails, invalid_emails = emails.partition { |email| valid_email?(email) }
@ -99,4 +98,8 @@ class InvitationsController < ApplicationController
session[key] = nil
return value
end
def inviter_params
params.require(:email_inviter).permit(:message, :locale, :emails)
end
end

View file

@ -33,7 +33,7 @@ class ProfilesController < ApplicationController
def update
# upload and set new profile photo
@profile_attrs = params.require(:profile).permit(:first_name, :last_name, :gender, :bio, :location, :searchable, :tag_string, :nsfw, :date => [:year, :month, :day]) || {}
@profile_attrs = profile_params
munge_tag_string
@ -78,4 +78,8 @@ class ProfilesController < ApplicationController
end
@profile_attrs[:tag_string] = (params[:tags]) ? params[:tags].gsub(',',' ') : ""
end
def profile_params
params.require(:profile).permit(:first_name, :last_name, :gender, :bio, :location, :searchable, :tag_string, :nsfw, :date => [:year, :month, :day]) || {}
end
end

View file

@ -1,5 +1,4 @@
class Block < ActiveRecord::Base
belongs_to :person
belongs_to :user

View file

@ -326,7 +326,8 @@ class User < ActiveRecord::Base
params[:image_url_small] = photo.url(:thumb_small)
end
params.stringify_keys!.slice!(*(Profile.column_names+['tag_string', 'date']))
params.stringify_keys!
params.slice!(*(Profile.column_names+['tag_string', 'date']))
if self.profile.update_attributes(params)
deliver_profile_update
true

View file

@ -1 +1,2 @@
# Please remove when migrating to Rails 4
ActiveRecord::Base.send(:include, ActiveModel::ForbiddenAttributesProtection)