Skip to content

Commit

Permalink
#56 model and relations created
Browse files Browse the repository at this point in the history
  • Loading branch information
MinaHany94 committed Apr 6, 2015
1 parent feb32e6 commit a3af75e
Show file tree
Hide file tree
Showing 13 changed files with 2,270 additions and 19 deletions.
40 changes: 22 additions & 18 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,12 @@ GEM
tzinfo (~> 1.1)
arel (6.0.0)
bcrypt (3.1.10)
bcrypt (3.1.10-x86-mingw32)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
builder (3.2.2)
byebug (3.5.1)
columnize (~> 0.8)
debugger-linecache (~> 1.2)
slop (~> 3.6)
byebug (4.0.5)
columnize (= 0.9.0)
cancan (1.6.10)
carrierwave (0.10.0)
activemodel (>= 3.2.0)
Expand All @@ -54,13 +53,12 @@ GEM
coffee-rails (4.1.0)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.0)
coffee-script (2.3.0)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.9.1)
coffee-script-source (1.8.0)
columnize (0.9.0)
debug_inspector (0.0.2)
debugger-linecache (1.2.0)
devise (3.4.1)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
Expand All @@ -69,14 +67,14 @@ GEM
thread_safe (~> 0.1)
warden (~> 1.2.3)
erubis (2.7.0)
execjs (2.4.0)
execjs (2.5.0)
font-awesome-rails (4.3.0.0)
railties (>= 3.2, < 5.0)
globalid (0.3.3)
activesupport (>= 4.1.0)
hike (1.2.3)
i18n (0.7.0)
jbuilder (2.2.11)
jbuilder (2.2.12)
activesupport (>= 3.0.0, < 5)
multi_json (~> 1.2)
jquery-rails (4.0.3)
Expand All @@ -89,12 +87,13 @@ GEM
mail (2.6.3)
mime-types (>= 1.16, < 3)
mime-types (2.4.3)
mini_magick (4.1.0)
mini_portile (0.6.2)
minitest (5.5.1)
multi_json (1.11.0)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
nokogiri (1.6.6.2-x86-mingw32)
mini_portile (~> 0.6.0)
orm_adapter (0.5.0)
rack (1.6.0)
rack-test (0.6.3)
Expand All @@ -112,11 +111,11 @@ GEM
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.5)
rails-dom-testing (1.0.6)
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6.0)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.1)
rails-html-sanitizer (1.0.2)
loofah (~> 2.0)
railties (4.2.0)
actionpack (= 4.2.0)
Expand All @@ -125,14 +124,15 @@ GEM
thor (>= 0.18.1, < 2.0)
rake (10.4.2)
rdoc (4.2.0)
json (~> 1.4)
redactor-rails (0.5.0)
devise
mime-types
orm_adapter
responders (2.1.0)
railties (>= 4.2.0, < 5)
sass (3.4.13)
sass-rails (5.0.1)
sass-rails (5.0.3)
railties (>= 4.0.0, < 5.0)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
Expand All @@ -141,8 +141,7 @@ GEM
sdoc (0.4.1)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
slop (3.6.0)
spring (1.3.3)
spring (1.3.4)
sprockets (2.12.3)
hike (~> 1.2)
multi_json (~> 1.0)
Expand All @@ -153,8 +152,9 @@ GEM
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
sqlite3 (1.3.10)
sqlite3 (1.3.10-x86-mingw32)
thor (0.19.1)
thread_safe (0.3.4)
thread_safe (0.3.5)
tilt (1.4.1)
turbolinks (2.5.3)
coffee-rails
Expand All @@ -165,30 +165,33 @@ GEM
railties (~> 4.1)
tzinfo (1.2.2)
thread_safe (~> 0.1)
tzinfo-data (1.2015.2)
tzinfo (>= 1.0.0)
uglifier (2.7.1)
execjs (>= 0.3.0)
json (>= 1.8.0)
warden (1.2.3)
rack (>= 1.0)
web-console (2.1.1)
web-console (2.1.2)
activemodel (>= 4.0)
binding_of_caller (>= 0.7.2)
railties (>= 4.0)
sprockets-rails (>= 2.0, < 4.0)

PLATFORMS
ruby
x86-mingw32

DEPENDENCIES
byebug
cancan
carrierwave
coffee-rails (~> 4.1.0)
coffee-script-source (= 1.8.0)
devise
font-awesome-rails
jbuilder (~> 2.0)
jquery-rails
mini_magick
rails (= 4.2.0)
redactor-rails
sass-rails (~> 5.0)
Expand All @@ -197,5 +200,6 @@ DEPENDENCIES
sqlite3
turbolinks
twitter-bootstrap-rails
tzinfo-data
uglifier (>= 1.3.0)
web-console (~> 2.0)
3 changes: 3 additions & 0 deletions app/models/magazine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
# 5.4.2015
# Magazines model
class Magazine < ActiveRecord::Base
has_many :requestjoiningmagazines
has_many :users, through: :requestjoiningmagazines

# Author: Mohammed El-Ansary
# 5.4.2015
# The uploader to Image field
Expand Down
4 changes: 4 additions & 0 deletions app/models/requestjoiningmagazine.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Requestjoiningmagazine < ActiveRecord::Base
belongs_to :user
belongs_to :magazine
end
3 changes: 3 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# User Model
class User < ActiveRecord::Base
has_many :requestjoiningmagazines
has_many :magazines, through: :requestjoiningmagazines

# to upload avatar for user
mount_uploader :avatar, AvatarUploader

Expand Down
Binary file modified db/development.sqlite3
Binary file not shown.
12 changes: 12 additions & 0 deletions db/migrate/20150406201640_create_requestjoiningmagazines.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class CreateRequestjoiningmagazines < ActiveRecord::Migration
def change
create_table :requestjoiningmagazines do |t|
t.references :user, index: true
t.references :magazine, index: true

t.timestamps null: false
end
add_foreign_key :requestjoiningmagazines, :users
add_foreign_key :requestjoiningmagazines, :magazines
end
end
12 changes: 11 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20150405142118) do
ActiveRecord::Schema.define(version: 20150406201640) do

create_table "articles", force: :cascade do |t|
t.string "title"
Expand Down Expand Up @@ -70,6 +70,16 @@
t.datetime "updated_at", null: false
end

create_table "requestjoiningmagazines", force: :cascade do |t|
t.integer "user_id"
t.integer "magazine_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end

add_index "requestjoiningmagazines", ["magazine_id"], name: "index_requestjoiningmagazines_on_magazine_id"
add_index "requestjoiningmagazines", ["user_id"], name: "index_requestjoiningmagazines_on_user_id"

create_table "users", force: :cascade do |t|
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
Expand Down
Loading

0 comments on commit a3af75e

Please sign in to comment.