小编Ric*_*een的帖子

有没有办法将javascript变量传递给html.erb中的ruby方法

我正在尝试将变量传递给方法.这是一个例子:

<script>
  var b = 1
  var c = "string" + "<%= method.a(b).to_s%>"
</script>
Run Code Online (Sandbox Code Playgroud)

这不起作用.

这有效:

<% @b = 1%>
<script>
  var c = "string" + "<%= method.a(@b).to_s%>"
</script>
Run Code Online (Sandbox Code Playgroud)

任何想法,将不胜感激.

javascript ruby ruby-on-rails

5
推荐指数
1
解决办法
4961
查看次数

EWS ruby​​观点批量订阅推送通知

我正在使用perspective gem来订阅microsoft exchange通知服务.到目前为止,我设法通过使用订阅方法订阅单个文件夹:https://github.com/WinRb/Viewpoint/blob/bcda30abdab99f52270f2c24a1c78364c986d967/lib/ews/soap/exchange_notification.rb

我尝试使用属于同一服务器上不同帐户的不同文件夹ID传递多个哈希值.

client.ews.subscribe(
[{ :push_subscription_request => {
  :folder_ids =>  [{id: calendar[:id], change_key: calendar[:change_key]}],
  :subscribe_to_all_folders => true,
  :event_types=>  %w{CopiedEvent CreatedEvent DeletedEvent MovedEvent},
  :status_frequency => 1,
  :uRL => 'https://51.ngrok.io/ews_watch',
}, 
{same again with different calendar ids}]
)
Run Code Online (Sandbox Code Playgroud)

我收到了来自ews的回复,但仅限于一个日历文件夹.

有谁知道如何批量订阅同一服务器上的多个邮箱,以便我从ews服务器收到批量推送通知,而不是为每个订阅获得一个?

谢谢

ruby ruby-on-rails exchangewebservices microsoft-exchange viewpoint

5
推荐指数
1
解决办法
120
查看次数

rails弹性搜索关系属性未编入索引

基本上我有3个模型(书,章,作者),我想在索引章节时包含一些书籍和作者属性.

这是我的章节.rb

class Chapter < ActiveRecord::Base
  belongs_to :book, :counter_cache => true
  include Elasticsearch::Model

  index_name [Rails.env, model_name.collection.gsub(/\//, '-')].join('_')

    mappings  do
      indexes :id, type: :integer
      indexes :title, type: :string
      indexes :description, type: :string
      indexes :content, type: :string
      indexes :updated_at, type: :date # Date example
      indexes :book_title
      indexes :book_type
      indexes :author_name
      indexes :book_id
    end

  def book_title
    book.title
  end
  def book_type
    book.book_type
  end
  def author_name
   " #{book.author.firstname} #{book.author.lastname} "
  end

  def to_indexed_json
    to_json methods: [:book_title, :book_type, :author_name]
  end
end
Run Code Online (Sandbox Code Playgroud)

http:// localhost:9200/development_chapters/_mapping?pretty显示正确的映射

{ …
Run Code Online (Sandbox Code Playgroud)

ruby ruby-on-rails elasticsearch

3
推荐指数
1
解决办法
906
查看次数