-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from josefzacek/layout-update-basic-messages-i…
…mplementation Layout update basic messages implementation
- Loading branch information
Showing
12 changed files
with
67 additions
and
13 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,8 @@ | ||
$(document).on('turbolinks:load', function() { | ||
$('#new_message').on('keypress', function(e) { | ||
if(e && e.keyCode == 13){ | ||
e.preventDefault(); | ||
$(this).submit(); | ||
} | ||
}); | ||
}); |
File renamed without changes.
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,3 +1,13 @@ | ||
@import "bootstrap-sprockets"; | ||
@import "bootstrap"; | ||
@import 'devise_flash_messages'; | ||
|
||
.container-fluid.content-container { | ||
padding-top: 70px; | ||
} | ||
|
||
.sidebar-fixed-position { | ||
position: fixed; | ||
top: 70; | ||
left: 0; | ||
} |
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 Messages 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
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,21 @@ | ||
class MessagesController < ApplicationController | ||
before_action :authenticate_user! | ||
before_action :set_chatroom | ||
|
||
def create | ||
message = @chatroom.messages.new(message_params) | ||
message.user = current_user | ||
message.save | ||
redirect_to @chatroom | ||
end | ||
|
||
private | ||
|
||
def set_chatroom | ||
@chatroom = Chatroom.find(params[:chatroom_id]) | ||
end | ||
|
||
def message_params | ||
params.require(:message).permit(:body) | ||
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,2 @@ | ||
module MessagesHelper | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
p | ||
strong Chatroom name: | ||
= @chatroom.name | ||
|
||
|
||
div data-behavior='messages' | ||
- @messages.each do |message| | ||
div | ||
strong = message.user.username | ||
|: | ||
= message.body | ||
|
||
= form_for [@chatroom, Message.new] do |f| | ||
= f.text_area :body, rows: 1, autofocus: true, class: 'form-control' |
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 |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
|
||
resources :chatrooms do | ||
resource :chatroom_users | ||
resources :messages | ||
end | ||
|
||
root to: 'chatrooms#index' | ||
|