Skip to content

Instantly share code, notes, and snippets.

@sebabelmar
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebabelmar/ab2e181c9ea4204de427 to your computer and use it in GitHub Desktop.
Save sebabelmar/ab2e181c9ea4204de427 to your computer and use it in GitHub Desktop.
Ginny's p10
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
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