Skip to content

Commit

Permalink
Protected Gallery and Event models against mass assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
mhartl committed Oct 9, 2008
1 parent 9eb0745 commit 074a05d
Show file tree
Hide file tree
Showing 26 changed files with 156 additions and 120 deletions.
2 changes: 1 addition & 1 deletion app/controllers/galleries_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def new
end

def create
@gallery = Gallery.new(params[:gallery].merge(:person => current_person))
@gallery = current_person.galleries.build(params[:galleries])
respond_to do |format|
if @gallery.save
flash[:success] = "Gallery successfully created"
Expand Down
8 changes: 4 additions & 4 deletions app/models/activity.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# == Schema Information
# Schema version: 28
# Schema version: 20080916002106
#
# Table name: activities
#
# id :integer(11) not null, primary key
# id :integer(4) not null, primary key
# public :boolean(1)
# item_id :integer(11)
# person_id :integer(11)
# item_id :integer(4)
# person_id :integer(4)
# item_type :string(255)
# created_at :datetime
# updated_at :datetime
Expand Down
12 changes: 7 additions & 5 deletions app/models/all_person.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# == Schema Information
# Schema version: 28
# Schema version: 20080916002106
#
# Table name: people
#
# id :integer(11) not null, primary key
# id :integer(4) not null, primary key
# email :string(255)
# name :string(255)
# remember_token :string(255)
Expand All @@ -12,9 +12,9 @@
# remember_token_expires_at :datetime
# last_contacted_at :datetime
# last_logged_in_at :datetime
# forum_posts_count :integer(11) default(0), not null
# blog_post_comments_count :integer(11) default(0), not null
# wall_comments_count :integer(11) default(0), not null
# forum_posts_count :integer(4) default(0), not null
# blog_post_comments_count :integer(4) default(0), not null
# wall_comments_count :integer(4) default(0), not null
# created_at :datetime
# updated_at :datetime
# admin :boolean(1) not null
Expand All @@ -24,6 +24,8 @@
# wall_comment_notifications :boolean(1) default(TRUE)
# blog_comment_notifications :boolean(1) default(TRUE)
# email_verified :boolean(1)
# avatar_id :integer(4)
# identity_url :string(255)
#

class AllPerson < Person
Expand Down
6 changes: 3 additions & 3 deletions app/models/blog.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# == Schema Information
# Schema version: 28
# Schema version: 20080916002106
#
# Table name: blogs
#
# id :integer(11) not null, primary key
# person_id :integer(11)
# id :integer(4) not null, primary key
# person_id :integer(4)
# created_at :datetime
# updated_at :datetime
#
Expand Down
21 changes: 10 additions & 11 deletions app/models/blog_post.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
# == Schema Information
# Schema version: 28
# Schema version: 20080916002106
#
# Table name: posts
#
# id :integer(11) not null, primary key
# blog_id :integer(11)
# topic_id :integer(11)
# person_id :integer(11)
# title :string(255)
# body :text
# blog_post_comments_count :integer(11) default(0), not null
# type :string(255)
# created_at :datetime
# updated_at :datetime
# id :integer(4) not null, primary key
# blog_id :integer(4)
# topic_id :integer(4)
# person_id :integer(4)
# title :string(255)
# body :text
# type :string(255)
# created_at :datetime
# updated_at :datetime
#

class BlogPost < Post
Expand Down
8 changes: 4 additions & 4 deletions app/models/comment.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# == Schema Information
# Schema version: 28
# Schema version: 20080916002106
#
# Table name: comments
#
# id :integer(11) not null, primary key
# commenter_id :integer(11)
# commentable_id :integer(11)
# id :integer(4) not null, primary key
# commenter_id :integer(4)
# commentable_id :integer(4)
# commentable_type :string(255) default(""), not null
# body :text
# created_at :datetime
Expand Down
12 changes: 6 additions & 6 deletions app/models/communication.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# == Schema Information
# Schema version: 28
# Schema version: 20080916002106
#
# Table name: communications
#
# id :integer(11) not null, primary key
# id :integer(4) not null, primary key
# subject :string(255)
# content :text
# parent_id :integer(11)
# sender_id :integer(11)
# recipient_id :integer(11)
# parent_id :integer(4)
# sender_id :integer(4)
# recipient_id :integer(4)
# sender_deleted_at :datetime
# sender_read_at :datetime
# recipient_deleted_at :datetime
Expand All @@ -17,7 +17,7 @@
# type :string(255)
# created_at :datetime
# updated_at :datetime
# conversation_id :integer(11)
# conversation_id :integer(4)
#

class Communication < ActiveRecord::Base
Expand Down
10 changes: 5 additions & 5 deletions app/models/connection.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# == Schema Information
# Schema version: 28
# Schema version: 20080916002106
#
# Table name: connections
#
# id :integer(11) not null, primary key
# person_id :integer(11)
# contact_id :integer(11)
# status :integer(11)
# id :integer(4) not null, primary key
# person_id :integer(4)
# contact_id :integer(4)
# status :integer(4)
# accepted_at :datetime
# created_at :datetime
# updated_at :datetime
Expand Down
4 changes: 2 additions & 2 deletions app/models/conversation.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# == Schema Information
# Schema version: 28
# Schema version: 20080916002106
#
# Table name: conversations
#
# id :integer(11) not null, primary key
# id :integer(4) not null, primary key
#

class Conversation < ActiveRecord::Base
Expand Down
6 changes: 3 additions & 3 deletions app/models/email_verification.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# == Schema Information
# Schema version: 28
# Schema version: 20080916002106
#
# Table name: email_verifications
#
# id :integer(11) not null, primary key
# person_id :integer(11)
# id :integer(4) not null, primary key
# person_id :integer(4)
# code :string(255)
# created_at :datetime
# updated_at :datetime
Expand Down
20 changes: 20 additions & 0 deletions app/models/event.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
# == Schema Information
# Schema version: 20080916002106
#
# Table name: events
#
# id :integer(4) not null, primary key
# title :string(255) default(""), not null
# description :string(255)
# person_id :integer(4) not null
# start_time :datetime not null
# end_time :datetime
# reminder :boolean(1)
# created_at :datetime
# updated_at :datetime
# event_attendees_count :integer(4) default(0)
# privacy :integer(4) not null
#

class Event < ActiveRecord::Base
include ActivityLogger

attr_accessible :title, :description

MAX_DESCRIPTION_LENGTH = MAX_STRING_LENGTH
MAX_TITLE_LENGTH = 40
PRIVACY = { :public => 1, :contacts => 2 }
Expand Down
10 changes: 10 additions & 0 deletions app/models/event_attendee.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# == Schema Information
# Schema version: 20080916002106
#
# Table name: event_attendees
#
# id :integer(4) not null, primary key
# person_id :integer(4)
# event_id :integer(4)
#

class EventAttendee < ActiveRecord::Base
include ActivityLogger

Expand Down
8 changes: 4 additions & 4 deletions app/models/feed.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# == Schema Information
# Schema version: 28
# Schema version: 20080916002106
#
# Table name: feeds
#
# id :integer(11) not null, primary key
# person_id :integer(11)
# activity_id :integer(11)
# id :integer(4) not null, primary key
# person_id :integer(4)
# activity_id :integer(4)
#

class Feed < ActiveRecord::Base
Expand Down
6 changes: 3 additions & 3 deletions app/models/forum.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# == Schema Information
# Schema version: 28
# Schema version: 20080916002106
#
# Table name: forums
#
# id :integer(11) not null, primary key
# id :integer(4) not null, primary key
# name :string(255)
# description :text
# topics_count :integer(11) default(0), not null
# topics_count :integer(4) default(0), not null
# created_at :datetime
# updated_at :datetime
#
Expand Down
21 changes: 10 additions & 11 deletions app/models/forum_post.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
# == Schema Information
# Schema version: 28
# Schema version: 20080916002106
#
# Table name: posts
#
# id :integer(11) not null, primary key
# blog_id :integer(11)
# topic_id :integer(11)
# person_id :integer(11)
# title :string(255)
# body :text
# blog_post_comments_count :integer(11) default(0), not null
# type :string(255)
# created_at :datetime
# updated_at :datetime
# id :integer(4) not null, primary key
# blog_id :integer(4)
# topic_id :integer(4)
# person_id :integer(4)
# title :string(255)
# body :text
# type :string(255)
# created_at :datetime
# updated_at :datetime
#

class ForumPost < Post
Expand Down
14 changes: 8 additions & 6 deletions app/models/gallery.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
# == Schema Information
# Schema version: 28
# Schema version: 17
# Schema version: 20080916002106
#
# Table name: galleries
#
# id :integer(11) not null, primary key
# person_id :integer(11)
# id :integer(4) not null, primary key
# person_id :integer(4)
# title :string(255)
# description :string(255)
# photos_count :integer(11) default(0), not null
# primary_photo_id :integer(11)
# photos_count :integer(4) default(0), not null
# primary_photo_id :integer(4)
# created_at :datetime
# updated_at :datetime
#

class Gallery < ActiveRecord::Base
include ActivityLogger

attr_accessible :title, :description

belongs_to :person
has_many :photos, :dependent => :destroy, :order => :position
has_many :activities, :foreign_key => "item_id", :dependent => :destroy
Expand Down
12 changes: 6 additions & 6 deletions app/models/message.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# == Schema Information
# Schema version: 28
# Schema version: 20080916002106
#
# Table name: communications
#
# id :integer(11) not null, primary key
# id :integer(4) not null, primary key
# subject :string(255)
# content :text
# parent_id :integer(11)
# sender_id :integer(11)
# recipient_id :integer(11)
# parent_id :integer(4)
# sender_id :integer(4)
# recipient_id :integer(4)
# sender_deleted_at :datetime
# sender_read_at :datetime
# recipient_deleted_at :datetime
Expand All @@ -17,7 +17,7 @@
# type :string(255)
# created_at :datetime
# updated_at :datetime
# conversation_id :integer(11)
# conversation_id :integer(4)
#

class Message < Communication
Expand Down
6 changes: 3 additions & 3 deletions app/models/page_view.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# == Schema Information
# Schema version: 28
# Schema version: 20080916002106
#
# Table name: page_views
#
# id :integer(11) not null, primary key
# id :integer(4) not null, primary key
# request_url :string(200)
# ip_address :string(16)
# referer :string(200)
# user_agent :string(200)
# created_at :datetime
# updated_at :datetime
# person_id :integer(11)
# person_id :integer(4)
#

class PageView < ActiveRecord::Base
Expand Down
Loading

0 comments on commit 074a05d

Please sign in to comment.