The Twilio number can be associated with a callback URL which it will send a POST request to when it receives an SMS. This callback URL should be customized to point to a controller in your app that you will use for processing SMS. From there, you can just read the params hash for details of the SMS message received. Of note: params['From'] and params['Body']. Store the text from those params into any model you like!

Twilio Callback URL

http<s>://<your domain.com>/sms

Route

resource :sms, only: :create

Controller

class SmsController < ApplicationController
skip_before_filter :force_ssl # You may need this if your app uses https normally
def create
# Do something with params['From'] -- contains the phone number the SMS came from
# Do something with params['Body'] -- contains the text sent in the SMS
# <Reponse/> is the minimum to indicate a "no response" from Twilio
render xml: "<Response/>"
end
end

Email codedump link for Twilio: Receive SMS and Do Something With Body Content