Reputation: 17
I am really hoping someone can help me. I am attempting to integrate OpenTok on my Ruby On Rails application on my already built app. I have used the following article to attempt the integration and to adapt it to my specific site. I've followed the step by step instruction here: https://railsfornovice.wordpress.com/2013/01/01/video-chatting-in-ruby-on-rails/
I need help because I am currently getting the error message:
uninitialized constant OpenTok::OpenTokSDK
and it appears it is not authenticating with Tokbox.
Here is my code:
def index
@rooms = Room.where(:public => true).order("created_at DESC")
@new_room = Room.new
end
def create
session = @opentok.create_session request.remote_addr
params[:room][:sessionId] = session.session_id
@new_room = Room.new(params[:room])
respond_to do |format|
if @new_room.save
format.html { redirect_to("/party/"+@new_room.id.to_s) }
else
format.html { render :controller => 'rooms',
:action => "index" }
end
end
end
def party
@room = Room.find(params[:id])
@tok_token = @opentok.generate_token :session_id =>@room.sessionId
end
Any help is greatly appreciated.
Thanks, Andrew
Upvotes: 0
Views: 987
Reputation: 1
For { @new_room = Room.new(params[:room]) }
you should change it to @new_room=Room.new(room_params)
and create a private method like this:
def room_params
params.require(:room).permit(:name, :public, :sessionId)
end
Upvotes: 0
Reputation: 2901
The blog post you are following is a little outdated. You probably pulled down the latest version of the 'opentok' gem, so you need to update your code to use the latest API. Fortunately, there aren't too many changes, here are the updated methods:
def create
session = @opentok.create_session
params[:room][:sessionId] = session.session_id
@new_room = Room.new(params[:room])
respond_to do |format|
if @new_room.save
format.html { redirect_to(“/party/”+@new_room.id.to_s) }
else
format.html { render :controller => ‘rooms’, :action => “index” }
end
end
end
def party
@room = Room.find(params[:id])
@tok_token = @opentok.generate_token @room.sessionId
end
def config_opentok
if @opentok.nil?
@opentok = OpenTok::OpenTok.new YOUR_API_KEY, YOUR_SECRET_TOKEN
end
end
For further reference, take a look at the OpenTok Ruby SDK README
Upvotes: 2