Skip to content

Commit 6998645

Browse files
author
Tyler Davis
committed
added new, create, and show controller methods for mass_text_message.
1 parent 15ccc39 commit 6998645

File tree

6 files changed

+105
-2
lines changed

6 files changed

+105
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
class MassTextMessagesController < ApplicationController
2+
3+
before_action :require_login
4+
5+
def new
6+
end
7+
8+
def create
9+
@message = MassTextMessage.new(mass_text_message_params)
10+
if @message.save
11+
flash[:success] = "Mass Text Message successfully created!"
12+
redirect_to mass_text_message_path(@message)
13+
else
14+
flash[:error] = "Issue creating Mass Text Message: #{@message.errors.join("\t")}"
15+
redirect_to new_mass_text_messages_path
16+
end
17+
end
18+
19+
def update
20+
21+
end
22+
23+
def show
24+
@message = MassTextMessage.find(params[:id])
25+
end
26+
27+
28+
private
29+
def mass_text_message_params
30+
params.require(:mass_text_message).permit(:name, :content)
31+
end
32+
33+
34+
end

app/models/mass_text_message.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class MassTextMessage < ActiveRecord::Base
44
belongs_to :text_cohort
55
has_many :text_cohort_entries, through: :text_cohort
66

7-
7+
#attr_accessible :name, :content
88

99

1010
end
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<h1>Create New Mass Text Message</h1>
2+
<hr/>
3+
<br/>
4+
5+
<%= form_for MassTextMessage.new do |f| %>
6+
7+
Name of Message*: <%= f.text_field :name %>
8+
<br/>
9+
Content of Message**: <%= f.text_field :content %>
10+
<br/>
11+
<%= f.submit('Create Message') %>
12+
13+
<% end %>
14+
15+
<br/>
16+
17+
<p>(*this name is for you (core member) to keep track of, but is not sent in the actual text)</p>
18+
<p>(**to insert dynamic fields, use double curly braces, with fields that correspond to fields in the txt-cohort entries .csv file.
19+
For example, if you type "Hi, {{name}}, this is a text.", and you have an entry with the field name="Tyler", you will see "Hi Tyler, this is a text."</p>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<h1>Mass Text Message: "<%= @message.name %>"</h1>
2+
<br/>
3+
<hr/>
4+
<h4>Content:</h4>
5+
<div class="well">
6+
<p><%=@message.content%></p>
7+
</div>

config/routes.rb

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
TpsWebsite::Application.routes.draw do
22

3+
resources :mass_text_messages, :only => [:index, :new, :show, :create, :update ]
4+
5+
36
get ':controller(/:action(/:id))'
47
post ':controller(/:action(/:id))'
58
# The priority is based upon order of creation: first created -> highest priority.

db/schema.rb

+41-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#
1212
# It's strongly recommended that you check this file into your version control system.
1313

14-
ActiveRecord::Schema.define(version: 20141120023419) do
14+
ActiveRecord::Schema.define(version: 20150517202044) do
1515

1616
create_table "apps", force: true do |t|
1717
t.string "mentee_id"
@@ -65,6 +65,18 @@
6565
t.datetime "updated_at"
6666
end
6767

68+
create_table "events", force: true do |t|
69+
t.string "timestamp"
70+
t.string "person_id"
71+
t.string "event_type"
72+
t.string "title"
73+
t.string "description"
74+
t.string "flag"
75+
t.string "resolved"
76+
t.datetime "created_at"
77+
t.datetime "updated_at"
78+
end
79+
6880
create_table "highschools", force: true do |t|
6981
t.string "name"
7082
t.string "address"
@@ -77,6 +89,15 @@
7789
t.datetime "updated_at"
7890
end
7991

92+
create_table "mass_text_messages", force: true do |t|
93+
t.datetime "sent_at"
94+
t.string "content"
95+
t.string "name"
96+
t.integer "text_cohort_id"
97+
t.datetime "created_at"
98+
t.datetime "updated_at"
99+
end
100+
80101
create_table "mentee_outreach_responses", force: true do |t|
81102
t.string "mentee_id"
82103
t.string "first_name"
@@ -174,6 +195,25 @@
174195
t.datetime "updated_at"
175196
end
176197

198+
create_table "text_cohort_entries", force: true do |t|
199+
t.string "phone"
200+
t.string "fields_json"
201+
t.integer "text_cohort_id"
202+
t.datetime "created_at"
203+
t.datetime "updated_at"
204+
end
205+
206+
create_table "text_cohorts", force: true do |t|
207+
t.string "name"
208+
t.datetime "created_at"
209+
t.datetime "updated_at"
210+
end
211+
212+
create_table "user_sessions", force: true do |t|
213+
t.datetime "created_at"
214+
t.datetime "updated_at"
215+
end
216+
177217
create_table "users", force: true do |t|
178218
t.string "login"
179219
t.string "password"

0 commit comments

Comments
 (0)