Rails 4 で oEmbed 用のプロバイダーを作成しようとしています。ルート、コントローラー、およびアクションが作成されます。
しかし、oembed に必要なパラメーター (タイプ、バージョン、html など) を持つオブジェクトを作成できません。
私はこのようにしようとしていました:
class ServicesController < ApplicationController
def oembed
# get project ID
url = params[:url].split("/")
project_id = url[4]
@project = Project.find(project_id)
html = render_to_string :partial => "projects/oembed", :formats => [:html], :locals => { :project => @
# here's the problem:
oembed_response["type"] = "rich"
oembed_response["version"] = "1.0"
oembed_response["title"] = @project.name
oembed_response["html"] = html
respond_to do | format |
if(@project)
format.html { render :text => "Test" }
format.json { render json: oembed_response, status: :ok }
format.xml { render xml: oembed_response, status: :ok }
else
# error
end
end
end
end
私は常に次のエラーが発生します。
NameError (未定義のローカル変数またはメソッド
oembed_response' for #<ServicesController:0x007f9a8be579a0>): app/controllers/services_controller.rb:11:in
oembed'
通常行われているように、モデルなしで必要な属性と (強い) パラメータを持つカスタム オブジェクトを作成するにはどうすればよいですか?
何か不足していますか?
前もって感謝します!
よろしく、
クリ