Last active
August 29, 2015 14:19
-
-
Save sebabelmar/ab2e181c9ea4204de427 to your computer and use it in GitHub Desktop.
Ginny's p10
This file contains hidden or 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
post '/texts' do | |
# join the date and time to one field | |
# create instance of text using incoming data | |
# Saving date time as UNIX value in the database. | |
# In the data base this value is am integer, I changed the migration. | |
# Not using fancy Chronic just plain Time class on ruby | |
# get rid og Chronic from the gem file. | |
# to convert it back to date use Time.at(UNIX_VALUE) | |
# Try to use save instead of create and put and if statement... we can work on this when rails comes along. but look into it :D | |
# Check my project https://github.com/sebabelmar/sitter/blob/master/app/controllers/twilio_controller.rb | |
# This is how I wrap the API. Is a controller class or helper but get it out of the model | |
# YOU ROCK!!!! SUCCESS IN THE ASSESMENT. LET ME KNOW HOW IT GOES!! | |
# SEBA | |
date_time = Time.parse(params[:date] + " " + params[:time]).to_i | |
@text = Text.create( | |
recipient: params[:recipient], | |
number: params[:number], | |
message: params[:message], | |
date_time: date_time | |
) | |
redirect "/texts/#{@text.id}" | |
end |
This file contains hidden or 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
class CreateTexts < ActiveRecord::Migration | |
def change | |
create_table :texts do |t| | |
t.text :name | |
t.text :number | |
t.text :recipient | |
t.text :message | |
t.integer :date_time | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment