Tag: ruby on rails 3

gabba gem不跟踪不同的域名

我有一个UA帐户,该帐户连接到以下域: http ://www.mytestdomain.com,帐号为UA-123456-1 当我使用Gem跟踪域时,它运行良好: Gabba::Gabba.new(‘UA-123456-1’, ‘http://www.mytestdomain.com’, user_agent).page_view(‘index’, ‘index.html’) 但其他域无法跟踪: Gabba::Gabba.new(‘UA-123456-1’, ‘http://www.notmydomain.com’, user_agent).page_view(‘index’, ‘index.html’) 我该怎么做才能跟踪其他域名? 相关: 使用Gabba发送到Google Analytics的事件没有主机名

如何让nested3中的nested_attributes工作?

这是我的用户模型: class User :destroy accepts_nested_attributes_for :teacher, :allow_destroy => true attr_accessible :email, :password, :password_confirmation, :remember_me, :teacher_attributes end 这是我的老师模型: class Teacher < ActiveRecord::Base belongs_to :user attr_accessible :user_id, :first_name, :last_name validates_presence_of :user_id, :first_name, :last_name end 这是我的表格: registration_path(:user)) do |user| %> 除了这个东西不会“接受嵌套属性”我的开发日志说: WARNING: Can’t mass-assign protected attributes: teacher 我不知道它是否相关,但表单不是在teacher_attributes数组中生成字段或任何东西 – 它在教师内部。 我猜这是我的问题所在,但我不知道如何把它放在里面。 请帮忙。 谢谢!

在文本区域中处理多种标记语言

我现在想如何使用rails 3上的ruby在文本区域中处理多种标记语言(textile,markdown和bbcode)。 用户将能够选择他/她想要使用的标记语言,用该语言编写,然后视图将使用用户选择的标记语言来呈现文本。 我目前正在处理为每个文本区域存储字段,但我确信有更好的方法,我很乐意听取您的意见并提出更好的方法。

ActionView :: Template :: Error(在heroku上没有将Fixnum隐式转换为String

我正在使用Mongodb.App正在使用ROR应用程序在localhost上正常工作,但是当我在heroku中部署它时,我收到错误。 我的一个视图文件命令是这样的: @h=Portfolio.last.folders Portfolio是一个将字段文件夹作为数组的集合。 生产中的Mongodb包含这个。 即使我尝试在heroku rails控制台中做同样的事情我也得到了同样的错误: TypeError: no implicit conversion of Fixnum into String from /app/vendor/bundle/ruby/2.0.0/gems/moped-1.4.3/lib/moped/protocol/commands/authenticate.rb:35:in `+’ from /app/vendor/bundle/ruby/2.0.0/gems/moped-1.4.3/lib/moped/protocol/commands/authenticate.rb:35:in `digest’ from /app/vendor/bundle/ruby/2.0.0/gems/moped-1.4.3/lib/moped/protocol/commands/authenticate.rb:47:in `build_auth_command’ from /app/vendor/bundle/ruby/2.0.0/gems/moped-1.4.3/lib/moped/protocol/commands/authenticate.rb:25:in `initialize’ from /app/vendor/bundle/ruby/2.0.0/gems/moped-1.4.3/lib/moped/node.rb:488:in `new’ from /app/vendor/bundle/ruby/2.0.0/gems/moped-1.4.3/lib/moped/node.rb:488:in `login’ from /app/vendor/bundle/ruby/2.0.0/gems/moped-1.4.3/lib/moped/node.rb:48:in `block in apply_auth’ from /app/vendor/bundle/ruby/2.0.0/gems/moped-1.4.3/lib/moped/node.rb:47:in `each’ from /app/vendor/bundle/ruby/2.0.0/gems/moped-1.4.3/lib/moped/node.rb:47:in `apply_auth’ from /app/vendor/bundle/ruby/2.0.0/gems/moped-1.4.3/lib/moped/cluster.rb:250:in `with_secondary’ from /app/vendor/bundle/ruby/2.0.0/gems/moped-1.4.3/lib/moped/session/context.rb:104:in `with_node’ from /app/vendor/bundle/ruby/2.0.0/gems/moped-1.4.3/lib/moped/session/context.rb:43:in `query’ from /app/vendor/bundle/ruby/2.0.0/gems/moped-1.4.3/lib/moped/query.rb:115:in […]

缓存在路轨的俄国玩偶

我听说DHH和其他伟大的37Signal人谈了很多俄罗斯娃娃缓存,我理解它的概念,但我真的不知道如何将它应用到我的代码中。 你会怎么样? 新编辑:如何将gem应用于一段包含大量if语句的代码? “avatar topimg” %> “description”) %> “upload icon-upload” %> “description”) %> “upload icon-star” unless current_user.followees_by_type(“design”).blank? %> “description”) unless current_user.followees_by_type(“design”).blank? %> “invites_count”) unless current_user.current_invites “invite icon-plus “+(“blue” unless current_user.current_invites == 0).to_s unless current_user.current_invites “description”) unless current_user.current_invites “activity_count”) unless activity == 0 %> “upload icon-activity “+(“blue” unless activity == 0).to_s unless activity == 0 %> […]

有没有人知道带有分页的动态表的js lib?

我创建了一个返回JSON数据的rails控制器。 因此,我无法像往常一样使用rails在服务器上呈现数据。 我可以创建一个简单的JS,只需要获取JSON并创建一个表。 但我支持分页。 我从jquery插件看了几个这样的表,但他们不使用Bootstrap css,所以它在我的布局中看起来很讨厌。 有人遇到过这样的问题吗?

如何持续增加计数器缓存列?

假设我有一个计数器缓存,需要在每次页面加载时递增。 假设我有10个Web实例。 如何持续增加计数器缓存列? 一个Web实例可以轻松实现一致性。 但是在多个实例运行时,可能会出现竞争条件。 这是一个快速解释。 假设我的计数器缓存列称为foo_counts ,其起始值为0.如果同时加载2个Web实例,则两者都将计数视为0.当需要增加计数时。 它们都将计数从0增加到1。 我查看了http://guides.rubyonrails.org/active_record_querying.html#locking-records-for-update 任何想法将不胜感激。

嵌套模型和表单在Rails中具有一个直通关系

我正在尝试设置一个包含一些歌曲信息的表单。 现在是歌曲名称和歌曲艺术家。 到目前为止,这是我的一些代码。 歌曲模型*编辑 class Song :song_artist_map accepts_nested_attributes_for :artist end 艺术家模型 class Artist :song_artist_maps end SongArtistMap模型 class SongArtistMap < ActiveRecord::Base belongs_to :song belongs_to :artist end 歌曲控制器 def new @song = Song.new @song.artist.build end 在我的表单中,我添加了这段代码 现在我的表格中没有任何东西出现在艺术家身上。 因此,我需要一种方法,可以在添加歌曲时从表单添加艺术家,然后进行映射,或者如果艺术家已存在于我的数据库中,则只进行映射。 我知道我在这里做错了什么,有人可以帮忙吗? 谢谢!

如何让ldap与rails中的设计一起工作?

我正在使用设计,我尝试使用ldap,我的所有尝试都导致失败。 我已经关注了http://vimeo.com/13105005 ,我正在寻求帮助。 Started POST “/users/sign_in” for 127.0.0.1 at 2013-04-16 18:01:54 +0530 Processing by Devise::SessionsController#create as HTML Parameters: {“utf8″=>”✓”, “authenticity_token”=>”N7Xkqk8nHWqK4tgiCxyX4wFccSO8ozhy+nxXqS19arA=”, “user”=>{“email”=>”logesh@gmail.com”, “password”=>”[FILTERED]”, “remember_me”=>”0”}, “commit”=>”Sign in”} WARNING: Can’t verify CSRF token authenticity User Load (0.6ms) SELECT “users”.* FROM “users” WHERE “users”.”email” = ‘logesh@gmail.com’ LIMIT 1 LDAP: LDAP dn lookup: cn=logesh@gmail.com LDAP: LDAP search for login: cn=logesh@gmail.com […]

改进API调用和响应

TheChamp帮我解决了一系列哈希问题。 谢谢。 现在我想改进一下。 观点真的很混乱 将代码移动到模型,因此只调用实例变量将显示所需的结果。 就像航class类型的一个变量,出发时间,价格结构等。 根据某些条件,将结果排序在模型本身中。 与价格一样,默认为最低价。 获取API响应需要花费大量时间。 缓存响应的各种选项有哪些,因此结果是即时的。 此外,需要检查哪些值以确保缓存是新鲜的。 这是我的代码库。 (供您考虑,API响应的一部分 – http://jsfiddle.net/PP9N5/ ) 模型 class Cleartrip include HTTParty debug_output $stdout base_uri “api.staging.cleartrip.com/air/1.0/search” headers ‘X-CT-API-KEY’ => ‘xxxxxxxxxxxxxxxxxxxxxxxxxxx’ format :xml def self.get_flight response = get(“?from=DEL&to=BLR&depart-date=2014-08-10&adults=1&children=0&infants=0”) if response.success? response else raise response.message end end 调节器 # This does nothing expires_in 20.minutes, public: true @flight = […]