Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
157 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Place all the behaviors and hooks related to the matching controller here. | ||
# All this logic will automatically be available in application.js. | ||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Place all the styles related to the message controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
class MessagesController < ApplicationController | ||
|
||
def create | ||
@recipient = User.find(params[:id]) | ||
@message = Message.new() | ||
@message.content = params[:content] | ||
@message.user = current_user | ||
@message.save | ||
mes_recipient = MessageRecipient.new() | ||
mes_recipient.message_id = @message.id | ||
mes_recipient.user_id = 1 | ||
mes_recipient.save | ||
end | ||
|
||
def show | ||
@message = Message.find(params[:id]) | ||
end | ||
|
||
def index | ||
@messages = current_user.messages + current_user.recieved_messages | ||
end | ||
|
||
def update | ||
@message = Message.find(params[:id]) | ||
|
||
respond_to do |format| | ||
if @message.update_attributes(params[:message]) | ||
format.html { redirect_to @message, notice: 'message was successfully updated.' } | ||
format.json { head :ok } | ||
else | ||
format.html { render action: "edit" } | ||
format.json { render json: @message.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module MessageHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class Message < ActiveRecord::Base | ||
#Relations | ||
belongs_to :user | ||
has_many :message_recipients | ||
has_many :recipients, :through => :message_recipients, :source => :user | ||
#Validations | ||
validate :user_id, :presence => true | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class MessageRecipient < ActiveRecord::Base | ||
#Relations | ||
belongs_to :message | ||
belongs_to :user | ||
|
||
#Validations | ||
validate :user_id, :presence => true | ||
validate :message_id , :presence => true | ||
|
||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,19 @@ | ||
<header> | ||
<%= image_tag("logo.png", :alt => "Ruby School", :class => "round") %> | ||
<header> | ||
<%= image_tag("logo.png", :alt => "Ruby School", :class => "round") %> | ||
<nav class="round"> | ||
<ul> | ||
|
||
<li><%= link_to "Home", root_path %></li> | ||
<li><%= link_to "Users", :userslist %></li> | ||
<% if current_user %> | ||
<li><%= link_to "Edit Profile", edit_user_path(current_user.id) %></li> | ||
<li><%= link_to "Logout", :logout %></li> | ||
<li><%= link_to "my_downloads", :downloads %></li> | ||
<% else %> | ||
<li><%= link_to "my_downloads", :my_downloads %></li> | ||
|
||
<% else %> | ||
<li><%= link_to "Register", new_user_path %></li> | ||
<li><%= link_to "Login", :login %></li> | ||
<% end %> | ||
</ul> | ||
</nav> | ||
</nav> | ||
|
||
</header> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<head> | ||
<title>Social Network | <%= @title %></title> | ||
|
||
<!--[if lt IE 9]> | ||
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> | ||
<![endif]--> | ||
<%= stylesheet_link_tag 'blueprint/screen', :media => 'screen' %> | ||
<%= stylesheet_link_tag 'blueprint/print', :media => 'print' %> | ||
<!--[if lt IE 8]><%= stylesheet_link_tag 'blueprint/ie' %><![endif]--> | ||
<%= stylesheet_link_tag 'custom', :media => 'screen' %> | ||
<%= javascript_include_tag "application" %> | ||
<%= csrf_meta_tags %> | ||
</head> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<h1>Writing message to <%= @recipient.username %></h1> | ||
|
||
<%= form_for @message do |f| %> | ||
<div class="field"> | ||
<%= f.label :content %><br /> | ||
<%= f.text_field :content %> | ||
</div> | ||
<div class="actions"> | ||
<%= f.submit "Submit" %> | ||
</div> | ||
<% end %> | ||
<%= link_to 'Back', @recipient %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<% @messages.each do |message|%> | ||
<div class="field"> | ||
<%= message.content %> | ||
<%= message.user.username %> | ||
</div> | ||
|
||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<p> | ||
<b>From:</b> | ||
<%= @message.user.username %> | ||
</p> | ||
|
||
<p> | ||
<b>Message:</b> | ||
<%= @message.content %> | ||
</p> | ||
|
||
<%= link_to 'Back', :root %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,5 +14,3 @@ | |
</tr> | ||
</table> | ||
|
||
<h1>Social Network</h1> | ||
<%= link_to 'New User', new_user_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class CreateMessages < ActiveRecord::Migration | ||
def change | ||
create_table :messages do |t| | ||
t.integer :user_id | ||
t.text :content | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class CreateMessagesRecipients < ActiveRecord::Migration | ||
def change | ||
create_table :message_recipients do |t| | ||
t.integer :user_id | ||
t.integer :message_id | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |